Example usage for edu.stanford.nlp.ling WordLemmaTag lemma

List of usage examples for edu.stanford.nlp.ling WordLemmaTag lemma

Introduction

In this page you can find the example usage for edu.stanford.nlp.ling WordLemmaTag lemma.

Prototype

String lemma

To view the source code for edu.stanford.nlp.ling WordLemmaTag lemma.

Click Source Link

Usage

From source file:edu.jhu.agiga.StanfordAgigaSentence.java

License:Open Source License

public List<TreeGraphNode> getStanfordTreeGraphNodes(DependencyForm form) {
    if (this.nodes != null)
        return this.nodes;

    this.nodes = new ArrayList<TreeGraphNode>();
    // Add an explicit root node
    nodes.add(new TreeGraphNode(ROOT_LABEL));

    List<WordLemmaTag> labels = getStanfordWordLemmaTags();
    for (WordLemmaTag curToken : labels) {
        // Create the tree node
        TreeGraphNode treeNode = new TreeGraphNode(curToken);
        treeNode.label().setTag(curToken.tag());
        /**/*from  w  w  w.j a  va 2 s  . c o m*/
         * Caution, the order to call is to first setWord(), then setlemma()
         * From the Stanford source code:
         *   
        public void setWord(String word) {
        set(WordAnnotation.class, word);
        // pado feb 09: if you change the word, delete the lemma.
        remove(LemmaAnnotation.class);
        }
                
        public void setLemma(String lemma) {
        set(LemmaAnnotation.class, lemma);
        }
          */
        treeNode.label().setWord(curToken.word());
        treeNode.label().setLemma(curToken.lemma());
        nodes.add(treeNode);
    }

    List<AgigaTypedDependency> agigaDeps = getAgigaDeps(form);
    for (AgigaTypedDependency agigaDep : agigaDeps) {
        // Add one, since the tokens are zero-indexed but the TreeGraphNodes are one-indexed
        TreeGraphNode gov = nodes.get(agigaDep.getGovIdx() + 1);
        TreeGraphNode dep = nodes.get(agigaDep.getDepIdx() + 1);

        // Add gov/dep to TreeGraph
        gov.addChild(dep);
        dep.setParent(gov);
        require(dep.parent() == gov);
    }

    return nodes;
}