public abstract class TregexMatcher
extends java.lang.Object
TregexPattern
against a Tree
.
Usage should be similar to a Matcher
.Modifier and Type | Method and Description |
---|---|
boolean |
find()
Find the next match of the pattern on the tree.
|
boolean |
findAt(Tree node)
Similar to
find() , but matches only if node is
the root of the match. |
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.
|
HeadFinder |
getHeadFinder() |
abstract Tree |
getMatch()
Get the last matching tree -- that is, the tree node that matches the root node of the pattern.
|
Tree |
getNode(java.lang.String name)
Returns the node labeled with
name in the pattern. |
java.util.Set<java.lang.String> |
getNodeNames() |
java.lang.String |
getVariableString(java.lang.String var)
If there is a current match, and that match involves setting this
particular variable string, this returns that string.
|
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)
Resets 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.
|
public HeadFinder getHeadFinder()
public void reset()
public abstract boolean matches()
public boolean matchesAt(Tree node)
node
.node
- The node where the match is checkedpublic abstract Tree getMatch()
public boolean find()
public boolean findAt(Tree node)
find()
, but matches only if node
is
the root of the match. All other matches are ignored. If you
know you are looking for matches with a particular root, this is
much faster than iterating over all matches and taking only the
ones that work and faster than altering the tregex to match only
the correct node.
public boolean findNextMatchingNode()
public Tree getNode(java.lang.String name)
name
in the pattern.name
- the name of the node, specified in the pattern.public java.util.Set<java.lang.String> getNodeNames()
public java.lang.String getVariableString(java.lang.String var)