Package edu.stanford.nlp.trees

Examples of edu.stanford.nlp.trees.TreeGraphNode


          nodes = getStanfordTreeGraphNodes(form);

        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);
            // Create the typed dependency
            TypedDependency typedDep = new TypedDependency(GrammaticalRelation.valueOf(agigaDep.getType()), gov, dep);
            dependencies.add(typedDep);
        }
        return dependencies;
View Full Code Here


    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());
            /**
             * 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;
    }
View Full Code Here

      dependencies.add(new TypedDependency(relation, headWord, thisWord));
    }

    // Build GrammaticalStructure
    // TODO ideally submodule should just return GrammaticalStructure
    TreeGraphNode rootNode = new TreeGraphNode(root);
    return makeGrammaticalStructure(dependencies, rootNode);
  }
View Full Code Here

TOP

Related Classes of edu.stanford.nlp.trees.TreeGraphNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.