Search in sources :

Example 1 with MaltChainedException

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;
}
Also used : MaltChainedException(org.maltparser.core.exception.MaltChainedException) SentimentDependencyGraph(org.grupolys.samulan.util.SentimentDependencyGraph) TaggedTokenInformation(org.grupolys.samulan.util.TaggedTokenInformation)

Aggregations

SentimentDependencyGraph (org.grupolys.samulan.util.SentimentDependencyGraph)1 TaggedTokenInformation (org.grupolys.samulan.util.TaggedTokenInformation)1 MaltChainedException (org.maltparser.core.exception.MaltChainedException)1