edu.stanford.nlp.semgrex
Class SemgrexMatcher

java.lang.Object
  extended by edu.stanford.nlp.semgrex.SemgrexMatcher

public abstract class SemgrexMatcher
extends Object

A SemgrexMatcher can be used to match a SemgrexPattern against a SemanticGraph.

Usage should be the same as Matcher.

Author:
Chloe Kiddon

Method Summary
 boolean find()
          Find the next match of the pattern in the graph
 boolean findNextMatchingNode()
          Find the next match of the pattern in the graph such that the matching node (that is, the node matching the root node of the pattern) differs from the previous matching node.
 SemanticGraph getGraph()
          Returns the graph associated with this match.
abstract  IndexedWord getMatch()
          Get the last matching node -- that is, the node that matches the root node of the pattern.
 IndexedWord getNode(String name)
          Returns the node labeled with name in the pattern.
 Set<String> getNodeNames()
          Returns the set of names for named nodes in this pattern.
 Set<String> getRelationNames()
          Returns the set of names for named relations in this pattern.
 String getRelnString(String name)
           
abstract  boolean matches()
          Does the pattern match the graph? It's actually closer to java.util.regex's "lookingAt" in that the root of the graph has to match the root of the pattern but the whole tree does not have to be "accounted for".
 boolean matchesAt(IndexedWord node)
          Rests the matcher and tests if it matches in the graph when rooted at node.
 void reset()
          Resets the matcher so that its search starts over.
abstract  String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, 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 graph? It's actually closer to java.util.regex's "lookingAt" in that the root of the graph 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 node matches the pattern

matchesAt

public boolean matchesAt(IndexedWord node)
Rests the matcher and tests if it matches in the graph when rooted at node.

Returns:
whether the matcher matches at node

getMatch

public abstract IndexedWord getMatch()
Get the last matching node -- that is, the 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 in the graph

Returns:
whether there is a match somewhere in the graph

findNextMatchingNode

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

Returns:
true iff another matching node is found.

getNode

public IndexedWord getNode(String 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

getRelnString

public String getRelnString(String name)

getNodeNames

public Set<String> getNodeNames()
Returns the set of names for named nodes in this pattern. This is used as a convenience routine, when there are numerous patterns with named nodes to track.


getRelationNames

public Set<String> getRelationNames()
Returns the set of names for named relations in this pattern.


toString

public abstract String toString()
Overrides:
toString in class Object

getGraph

public SemanticGraph getGraph()
Returns the graph associated with this match.



Stanford NLP Group