Exemplo n.º 1
0
 /**
  * Returns any particle this <code>verb</code> may have
  *
  * @param verb
  * @param graph
  * @return
  */
 static IndexedWord getParticle(final IndexedWord verb, final SemanticGraph graph) {
   GrammaticalRelation reln =
       edu.stanford.nlp.trees.GrammaticalRelation.getRelation(
           edu.stanford.nlp.trees.EnglishGrammaticalRelations.PhrasalVerbParticleGRAnnotation
               .class);
   return graph.getChildWithReln(verb, reln);
 }
Exemplo n.º 2
0
 /**
  * Decides whether this word has a direct object.
  *
  * @param word the word to analyse
  * @param graph the sentence to which this word belongs
  * @return TRUE, if a direct object is present for this verb
  */
 static boolean hasDirectObjectNP(IndexedWord word, SemanticGraph graph) {
   GrammaticalRelation reln =
       edu.stanford.nlp.trees.GrammaticalRelation.getRelation(
           edu.stanford.nlp.trees.EnglishGrammaticalRelations.DirectObjectGRAnnotation.class);
   if (graph.hasChildWithReln(word, reln)) {
     String pos = graph.getChildWithReln(word, reln).get(PartOfSpeechAnnotation.class);
     if (pos.equalsIgnoreCase("NN")) {
       return true;
     }
   }
   return false;
 }
Exemplo n.º 3
0
 /**
  * Finds a direct object. ex: the chair in "move the chair"
  *
  * @param word
  * @param graph
  * @return
  */
 public static IndexedWord getDirectObject(IndexedWord word, SemanticGraph graph) {
   GrammaticalRelation reln =
       edu.stanford.nlp.trees.GrammaticalRelation.getRelation(
           edu.stanford.nlp.trees.EnglishGrammaticalRelations.DirectObjectGRAnnotation.class);
   return graph.getChildWithReln(word, reln);
 }
Exemplo n.º 4
0
 /**
  * Finds any prepositions relating to {@code word}. Requires a non-collapsed graph.
  *
  * @param word The word which is being modified
  * @param graph A basic graph (non-collapsed)
  * @return
  */
 static CoreLabel getPrepMod(IndexedWord word, SemanticGraph graph) {
   GrammaticalRelation reln =
       edu.stanford.nlp.trees.GrammaticalRelation.getRelation(
           EnglishGrammaticalRelations.PrepositionalModifierGRAnnotation.class);
   return graph.getChildWithReln(word, reln);
 }