Package edu.stanford.nlp.ling

Examples of edu.stanford.nlp.ling.IndexedWord


    Set<List<TypedDependency>> depLists = Generics.newHashSet();
    List<TypedDependency> children = govToDepMap.get(gov);

    if (depth > 0 && children != null) {
      for (TypedDependency child : children) {
        IndexedWord childNode = child.dep();
        if (childNode == null) continue;
        Set<List<TypedDependency>> childDepLists = getGovMaxChains(govToDepMap, childNode, depth-1);
        if (childDepLists.size() != 0) {
          for (List<TypedDependency> childDepList : childDepLists) {
            List<TypedDependency> depList = new ArrayList<TypedDependency>(childDepList.size() + 1);


  return new AddNode(nodeString, nodeName);
}

  @Override
  public void evaluate(SemanticGraph sg, SemgrexMatcher sm) {
    IndexedWord newNode = AddDep.fromCheapString(nodeString);
    sg.addVertex(newNode);
    addNamedNode(newNode, nodeName);
  }

    this.nodeName = nodeName;
  }

  @Override
  public void evaluate(SemanticGraph sg, SemgrexMatcher sm) {
   IndexedWord tgtNode = getNamedNode(nodeName, sm);
   for (SemanticGraphEdge edge : sg.incomingEdgeIterable(tgtNode)) {
     sg.removeEdge(edge);
   }
  }

  public String toString(CoreLabel.OutputFormat format) {
    return reln + "(" + gov.toString(format) + ", " + dep.toString(format) + ")";
  }

  public int compareTo(TypedDependency tdArg) {
    IndexedWord depArg = tdArg.dep();
    IndexedWord depThis = this.dep();
    int indexArg = depArg.index();
    int indexThis = depThis.index();

    if (indexThis > indexArg) {
      return 1;
    } else if (indexThis < indexArg) {
      return -1;

    for (TypedDependency rcmod : list) {
      if (rcmod.reln() != RELATIVE_CLAUSE_MODIFIER) {
        continue;
      }

      IndexedWord head = rcmod.gov();
      if (depNodes == null) {
        depNodes = Generics.newArrayList();
      } else {
        depNodes.clear();
      }

    Collection<TypedDependency> newTypedDeps = new ArrayList<TypedDependency>(list);

    // find typed deps of form conj(gov,dep)
    for (TypedDependency td : list) {
      if (EnglishGrammaticalRelations.getConjs().contains(td.reln())) {
        IndexedWord gov = td.gov();
        IndexedWord dep = td.dep();

        // look at the dep in the conjunct
        Set<TypedDependency> gov_relations = map.get(gov);
        // System.err.println("gov " + gov);
        if (gov_relations != null) {
          for (TypedDependency td1 : gov_relations) {
            // System.err.println("gov rel " + td1);
            IndexedWord newGov = td1.gov();
            // in the case of errors in the basic dependencies, it
            // is possible to have overlapping newGov & dep
            if (newGov.equals(dep)) {
              continue;
            }
            GrammaticalRelation newRel = td1.reln();
            if (newRel != ROOT) {
              if (rcmodHeads.contains(gov) && rcmodHeads.contains(dep)) {

  private static void collapseConj(Collection<TypedDependency> list) {
    List<IndexedWord> govs = Generics.newArrayList();
    // find typed deps of form cc(gov, dep)
    for (TypedDependency td : list) {
      if (td.reln() == COORDINATION) { // i.e. "cc"
        IndexedWord gov = td.gov();
        GrammaticalRelation conj = conjValue(td.dep().value());
        if (DEBUG) {
          System.err.println("Set conj to " + conj + " based on " + td);
        }

      }
    }

    // now substitute target of referent where possible
    for (TypedDependency ref : refs) {
      IndexedWord dep = ref.dep();// take the relative word
      IndexedWord ant = ref.gov();// take the antecedent
      for (TypedDependency td : list) {
        // the last condition below maybe shouldn't be necessary, but it has
        // helped stop things going haywire a couple of times (it stops the
        // creation of a unit cycle that probably leaves something else
        // disconnected) [cdm Jan 2010]

      if (rcmod.reln() != RELATIVE_CLAUSE_MODIFIER) {
        // we only add ref dependencies across relative clauses
        continue;
      }

      IndexedWord head = rcmod.gov();
      IndexedWord modifier = rcmod.dep();

      TypedDependency leftChild = null;
      for (TypedDependency child : list) {
        if (child.gov().equals(modifier) &&
            EnglishPatterns.RELATIVIZING_WORD_PATTERN.matcher(child.dep().value()).matches() &&

      if (xcomp.reln() != XCLAUSAL_COMPLEMENT) {
        // we only add extra nsubj dependencies to some xcomp dependencies
        continue;
      }

      IndexedWord modifier = xcomp.dep();
      IndexedWord head = xcomp.gov();

      boolean hasSubjectDaughter = false;
      boolean hasAux = false;
      List<IndexedWord> subjects = Generics.newArrayList();
      List<IndexedWord> objects = Generics.newArrayList();

TOP

Related Classes of edu.stanford.nlp.ling.IndexedWord

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.