use of org.maltparser.core.exception.MaltChainedException in project uuusa by aghie.
the class MaltParserWrapper method parse.
public SentimentDependencyGraph parse(List<TaggedTokenInformation> ttis) {
SentimentDependencyGraph sdg = null;
String[] tokens = new String[ttis.size()];
// System.out.println("MaltParserWrapper parse");
int i = 0;
for (TaggedTokenInformation tti : ttis) {
tokens[i] = tti.toConll();
i += 1;
}
// Parses the Swedish sentence above
String[] outputTokens;
try {
outputTokens = this.parser.parseTokens(tokens);
sdg = new SentimentDependencyGraph(String.join("\n", outputTokens));
// // Outputs the with the head index and dependency type information
// for (int j = 0; j < outputTokens.length; j++) {
// System.out.println(outputTokens[j]);
// }
} catch (MaltChainedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
// Terminates the parser model
try {
this.parser.terminateParserModel();
} catch (MaltChainedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return sdg;
}
Aggregations