edu.stanford.nlp.trees.tregex
Class TregexMatcher

java.lang.Object
  extended by edu.stanford.nlp.trees.tregex.TregexMatcher

public abstract class TregexMatcher
extends Object

A TregexMatcher can be used to match a TregexPattern against a Tree.

Usage should to be the same as Matcher.

@author Galen Andrew


Method Summary
 boolean find()
          Find the next match of the pattern on the tree
 boolean findNextMatchingNode()
          Find the next match of the pattern on the tree such that the matching node (that is, the tree node matching the root node of the pattern) differs from the previous matching node.
abstract  Tree getMatch()
          Get the last matching tree -- that is, the tree node that matches the root node of the pattern.
 Tree getNode(Object name)
          Returns the node labeled with name in the pattern.
static void main(String[] args)
          Look at a bunch of trees and tell where TreePattern and TregexPattern differ at all.
abstract  boolean matches()
          Does the pattern match the tree? It's actually closer to java.util.regex's "lookingAt" in that the root of the tree has to match the root of the pattern but the whole tree does not have to be "accounted for".
 boolean matchesAt(Tree node)
          Rests the matcher and tests if it matches on the tree when rooted at node.
 void reset()
          Resets the matcher so that its search starts over.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

reset

public void reset()
Resets the matcher so that its search starts over.


matches

public abstract boolean matches()
Does the pattern match the tree? It's actually closer to java.util.regex's "lookingAt" in that the root of the tree has to match the root of the pattern but the whole tree does not have to be "accounted for". Like with lookingAt the beginning of the string has to match the pattern, but the whole string doesn't have to be "accounted for".

Returns:
whether the tree matches the pattern

matchesAt

public boolean matchesAt(Tree node)
Rests the matcher and tests if it matches on the tree when rooted at node.

Parameters:
node -
Returns:
whether the matcher matches at node

getMatch

public abstract Tree getMatch()
Get the last matching tree -- that is, the tree node that matches the root node of the pattern. Returns null if there has not been a match.

Returns:
last match

find

public boolean find()
Find the next match of the pattern on the tree

Returns:
whether there is a match somewhere in the tree

findNextMatchingNode

public boolean findNextMatchingNode()
Find the next match of the pattern on the tree such that the matching node (that is, the tree node matching the root node of the pattern) differs from the previous matching node.

Returns:
true iff another matching node is found.

getNode

public Tree getNode(Object name)
Returns the node labeled with name in the pattern.

Parameters:
name - the name of the node, specified in the pattern.
Returns:
node labeled by the name

main

public static void main(String[] args)
                 throws Exception
Look at a bunch of trees and tell where TreePattern and TregexPattern differ at all. Use the -p option for hand-specifying the pattern. This was intended for debugging TregexPattern against TreePattern, and not for use by regular users, who should look at the main method of TregexPattern.

Parameters:
args - TreebankPath, RangesFilter
Throws:
Exception


Stanford NLP Group