Package edu.stanford.nlp.trees.tregex

Examples of edu.stanford.nlp.trees.tregex.TregexMatcher


      return matchedParts;
    }

    public void visitTree(Tree t) {
      int numMatches = 0;
      TregexMatcher match = p.matcher(t);
      List<Tree> matchedPartList = null; // initialize lazily, since usually most trees don't match!
      while (match.find()) {
        Tree curMatch = match.getMatch();
        //System.out.println("Found match is: " + curMatch);
        if (matchedPartList == null) matchedPartList = new ArrayList<Tree>();
        matchedPartList.add(curMatch);
        numMatches++;
      } // end while match.find()
View Full Code Here


    Set<Tree> nodeList = new LinkedHashSet<Tree>();
    for (TregexPattern p : targetPatterns) {    // cdm: I deleted: && nodeList.isEmpty()
      if (root.value() == null) {
        root.setValue("ROOT");
      }
      TregexMatcher m = p.matcher(root);
      while (m.find()) {
        if (m.getMatch() == t) {
          nodeList.add(m.getNode("target"));
          //System.out.println("found " + this + "(" + t + ", " + m.getNode("target") + ")");
        }
      }
    }
    return nodeList;
View Full Code Here

   * @param p A {@link TsurgeonPattern} to apply.
   * @param t the {@link Tree} to match against and perform surgery on.
   * @return t, which has been surgically modified.
   */
  public static Tree processPattern(TregexPattern matchPattern, TsurgeonPattern p, Tree t) {
    TregexMatcher m = matchPattern.matcher(t);
    while(m.find()) {
      t = p.evaluate(t,m);
      if(t==null)
        break;
      m = matchPattern.matcher(t);
    }
View Full Code Here

  public static Tree processPatternsOnTree(List<Pair<TregexPattern, TsurgeonPattern>> ops, Tree t) {
    matchedOnTree = false;
    for (Pair<TregexPattern,TsurgeonPattern> op : ops) {
      try {
        TregexMatcher m = op.first().matcher(t);
        while (m.find()) {
          matchedOnTree = true;
          t = op.second().evaluate(t,m);
          if (t == null) {
            return null;
          }
View Full Code Here

TOP

Related Classes of edu.stanford.nlp.trees.tregex.TregexMatcher

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.