This is the top-level class for the OpenCCG parser. It contains the main method. Here is the important stuff (assuming a default grammar file and no input parameters, and ignoring special input commands when running the tccg loop):
String grammarfile = "grammar.xml";
URL grammarURL = new File(grammarFile).toURL();
Grammar grammar = new Grammar(grammarURL);
Parser parser = new Parser(grammar);
Realizer realizer = new Realizer(grammar);
LineReader lineReader = ...
while (true) {
String input = lineReader.readLine("tccg> ");
try {
parse.parse(input.trim());
List parses = parser.getResult();
...
}
catch (ParseException pe) System.out.println(pe);
}
See also opennlp.ccg.grammar.Grammar.
No comments:
Post a Comment