Example usage for opennlp.tools.parser Parse parseParse

List of usage examples for opennlp.tools.parser Parse parseParse

Introduction

In this page you can find the example usage for opennlp.tools.parser Parse parseParse.

Prototype

public static Parse parseParse(String parse) 

Source Link

Document

Parses the specified tree-bank style parse string and return a Parse structure for that string.

Usage

From source file:es.ehu.si.ixa.pipe.parse.Annotate.java

/**
 * Takes as input a list of parse strings, one for line, and annotates the
 * headwords/*  w ww .j a v a  2s.c om*/
 * 
 * @param inputTrees
 * @return a list of parse trees with headwords annotated
 */
private String addHeadWordsToTreebank(List<String> inputTrees) {
    StringBuffer parsedDoc = new StringBuffer();
    for (String parseSent : inputTrees) {
        Parse parsedSentence = Parse.parseParse(parseSent);
        headFinder.printHeads(parsedSentence);
        parsedSentence.show(parsedDoc);
        parsedDoc.append("\n");
    }
    return parsedDoc.toString();
}

From source file:es.ehu.si.ixa.pipe.convert.Convert.java

/**
 * Reads a list of Parse trees and calls {@code getTokens} to create tokenized
 * oneline text.//from www  .j a v  a 2  s.  c  o m
 * 
 * @param inputTrees
 *          the list of trees in penn treebank format
 * @return the tokenized document the document tokens
 */
private String getTokensFromTree(List<String> inputTrees) {

    StringBuilder parsedDoc = new StringBuilder();
    for (String parseSent : inputTrees) {
        Parse parse = Parse.parseParse(parseSent);
        StringBuilder sentBuilder = new StringBuilder();
        getTokens(parse, sentBuilder);
        parsedDoc.append(sentBuilder.toString()).append("\n");
    }
    return parsedDoc.toString();
}

From source file:es.ehu.si.ixa.pipe.convert.Convert.java

/**
 * Reads a list of Parse trees and calls {@code getWordType} to create POS
 * training data in Word_POS form//ww w . j a v a2s .  com
 * 
 * @param inputTrees
 * @return the document with Word_POS sentences
 */
private String getPreTerminals(List<String> inputTrees) {

    StringBuilder parsedDoc = new StringBuilder();
    for (String parseSent : inputTrees) {
        Parse parse = Parse.parseParse(parseSent);
        StringBuilder sentBuilder = new StringBuilder();
        getWordType(parse, sentBuilder);
        parsedDoc.append(sentBuilder.toString()).append("\n");
    }
    return parsedDoc.toString();
}

From source file:es.ehu.si.ixa.pipe.convert.Convert.java

/**
 * It takes as input a semi-pruned penn treebank tree (e.g., with -NONE-
 * traces removed) via sed 's/-NONE-\s[\*A-Za-z0-9]*[\*]*[\-]*[A-Za-z0-9]*'
 * //from  www  .  j a  v  a2s .  c om
 * and prunes the empty trees remaining from the sed operation. The parseParse
 * function also removes function tags by default.
 * 
 * @param inputTrees
 * @return
 */
// TODO add the sed regexp to this function
private String normalizeParse(List<String> inputTrees) {
    StringBuilder parsedDoc = new StringBuilder();
    for (String parseSent : inputTrees) {
        Parse parse = Parse.parseParse(parseSent);
        Parse.pruneParse(parse);
        StringBuffer sentBuilder = new StringBuffer();
        parse.show(sentBuilder);
        parsedDoc.append(sentBuilder.toString()).append("\n");
    }
    return parsedDoc.toString();
}