-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRunSystem.java
More file actions
111 lines (88 loc) · 5.6 KB
/
Copy pathRunSystem.java
File metadata and controls
111 lines (88 loc) · 5.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package fyp;
import java.io.FileNotFoundException;
import java.io.IOException;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import org.apache.jena.ontology.OntModel;
import org.xml.sax.SAXException;
import net.sf.extjwnl.JWNLException;
public class RunSystem {
String generalPath, inFile, textSimplifierOutFile, sentenceAssocFile, anaphoraResolveOutFile, jenaOutputFile, jenaInputFile, questionFile, answerFile;
StanfordHandler stanfordHandler;
ExtJWNLHandler extJWNLHandler;
boolean isDefaultStory;
RunSystem(String inputFilePath, boolean isDefaultStory) throws FileNotFoundException, JWNLException {
generalPath = "C:/Users/Sadhana/workspace/System/src/fyp";
inFile = inputFilePath;
textSimplifierOutFile = "textSimplification.txt";
sentenceAssocFile = "sentenceAssociations.txt";
anaphoraResolveOutFile = "outputFile.txt";
jenaOutputFile = "KnowledgeBase.owl";
jenaInputFile = "C:/Users/Sadhana/workspace/System/src/fyp/SentenceOntology.owl";
questionFile = "questionFile.txt";
answerFile = "answerFile.txt";
stanfordHandler = new StanfordHandler();
extJWNLHandler = new ExtJWNLHandler();
this.isDefaultStory = isDefaultStory;
}
public void RunTextSimplifier() throws IOException, SAXException, ParserConfigurationException, TransformerException {
TextSimplifier textSimplifier;
AnaphoraResolver anaphoraResolver;
textSimplifier = new TextSimplifier(generalPath, inFile, textSimplifierOutFile, sentenceAssocFile, stanfordHandler);
textSimplifier.runTextSimplifier();
if(!isDefaultStory) {
System.out.println("I am in anaphora, now not opening anaphora");
anaphoraResolver = new AnaphoraResolver(generalPath, textSimplifierOutFile, anaphoraResolveOutFile, stanfordHandler);
}
else {
System.out.println("I am in anaphora, now opening anaphora");
System.out.println(inFile.substring(0, inFile.indexOf('.')));
anaphoraResolver = new AnaphoraResolver(generalPath, textSimplifierOutFile, anaphoraResolveOutFile, stanfordHandler, inFile.substring(0, inFile.indexOf('.'))+"_lookup.txt");
}
anaphoraResolver.runAnaphoraResolver();
}
public void RunQuestionModule() throws IOException, SAXException, ParserConfigurationException, TransformerException, JWNLException {
KnowledgeBaseCreator knowledgeBaseCreator, questionBaseCreator;
QuestionProcessor questionProcessor;
knowledgeBaseCreator = new KnowledgeBaseCreator(jenaInputFile, jenaOutputFile, generalPath, anaphoraResolveOutFile, sentenceAssocFile, stanfordHandler);
questionBaseCreator = new KnowledgeBaseCreator(jenaInputFile, jenaOutputFile, generalPath, questionFile, sentenceAssocFile, stanfordHandler);
questionProcessor = new QuestionProcessor(generalPath, questionFile, answerFile, stanfordHandler, extJWNLHandler, knowledgeBaseCreator.runKnowledgeCreator(true), questionBaseCreator.runKnowledgeCreator(false));
OntModel questionModel = questionBaseCreator.runKnowledgeCreator(false).ontModel;
questionModel.write(System.out);
OntModel paragraphModel = knowledgeBaseCreator.runKnowledgeCreator(true).ontModel;
paragraphModel.write(System.out);
questionProcessor.runQuestionProcessor();
}
public static void main(String args[]) throws IOException, SAXException, ParserConfigurationException, TransformerException, JWNLException {
RunSystem runSystem = new RunSystem("story1.txt", false);
//System.out.println((int)('m'));
TextSimplifier textSimplifier;
AnaphoraResolver anaphoraResolver;
KnowledgeBaseCreator knowledgeBaseCreator, questionBaseCreator;
QuestionProcessor questionProcessor;
StanfordHandler stanfordHandler;
ExtJWNLHandler extJWNLHandler;
stanfordHandler = new StanfordHandler();
extJWNLHandler = new ExtJWNLHandler();
textSimplifier = new TextSimplifier(runSystem.generalPath, runSystem.inFile, runSystem.textSimplifierOutFile, runSystem.sentenceAssocFile, stanfordHandler);
textSimplifier.runTextSimplifier();
if(!runSystem.isDefaultStory) {
System.out.println("I am in anaphora, now not opening anaphora");
anaphoraResolver = new AnaphoraResolver(runSystem.generalPath, runSystem.textSimplifierOutFile, runSystem.anaphoraResolveOutFile, stanfordHandler);
}
else {
System.out.println("I am in anaphora, now opening anaphora");
System.out.println(runSystem.inFile.substring(0, runSystem.inFile.indexOf('.')));
anaphoraResolver = new AnaphoraResolver(runSystem.generalPath, runSystem.textSimplifierOutFile, runSystem.anaphoraResolveOutFile, stanfordHandler, runSystem.inFile.substring(0, runSystem.inFile.indexOf('.'))+"_lookup.txt");
}
anaphoraResolver.runAnaphoraResolver();
knowledgeBaseCreator = new KnowledgeBaseCreator(runSystem.jenaInputFile, runSystem.jenaOutputFile, runSystem.generalPath, runSystem.anaphoraResolveOutFile, runSystem.sentenceAssocFile, stanfordHandler);
questionBaseCreator = new KnowledgeBaseCreator(runSystem.jenaInputFile, runSystem.jenaOutputFile, runSystem.generalPath, runSystem.questionFile, runSystem.sentenceAssocFile, stanfordHandler);
questionProcessor = new QuestionProcessor(runSystem.generalPath, runSystem.questionFile, runSystem.answerFile, stanfordHandler, extJWNLHandler, knowledgeBaseCreator.runKnowledgeCreator(true), questionBaseCreator.runKnowledgeCreator(false));
OntModel questionModel = questionBaseCreator.runKnowledgeCreator(false).ontModel;
questionModel.write(System.out);
OntModel paragraphModel = knowledgeBaseCreator.runKnowledgeCreator(true).ontModel;
paragraphModel.write(System.out);
questionProcessor.runQuestionProcessor();
}
}