edu.stanford.nlp.trees.tregex
Class TregexPatternCompiler

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

public class TregexPatternCompiler
extends Object

A class for compiling TregexPatterns with specific HeadFinders and or basicCategoryFunctions.

Author:
Galen Andrew

Field Summary
static TregexPatternCompiler defaultCompiler
           
 
Constructor Summary
TregexPatternCompiler()
           
TregexPatternCompiler(Function<String,String> basicCatFunction)
          A compiler that uses this basicCatFunction and the default HeadFinder.
TregexPatternCompiler(HeadFinder headFinder)
          A compiler that uses this HeadFinder and the default basicCategoryFunction
TregexPatternCompiler(HeadFinder headFinder, Function<String,String> basicCatFunction)
          A compiler that uses this HeadFinder and this basicCategoryFunction
 
Method Summary
 TregexPattern compile(String tregex)
          Create a TregexPattern from this tregex string using the headFinder and basicCat function this TregexPatternCompiler was created with.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultCompiler

public static TregexPatternCompiler defaultCompiler
Constructor Detail

TregexPatternCompiler

public TregexPatternCompiler()

TregexPatternCompiler

public TregexPatternCompiler(Function<String,String> basicCatFunction)
A compiler that uses this basicCatFunction and the default HeadFinder.

Parameters:
basicCatFunction - the function mapping Strings to Strings

TregexPatternCompiler

public TregexPatternCompiler(HeadFinder headFinder)
A compiler that uses this HeadFinder and the default basicCategoryFunction

Parameters:
headFinder - the HeadFinder

TregexPatternCompiler

public TregexPatternCompiler(HeadFinder headFinder,
                             Function<String,String> basicCatFunction)
A compiler that uses this HeadFinder and this basicCategoryFunction

Parameters:
headFinder - the HeadFinder
basicCatFunction - The function mapping Strings to Strings
Method Detail

compile

public TregexPattern compile(String tregex)
                      throws ParseException
Create a TregexPattern from this tregex string using the headFinder and basicCat function this TregexPatternCompiler was created with. Implementation note: If there is an invalid token in the Tregex parser, JavaCC will throw a TokenMgrError. This is a class that extends Error, not Exception (OMG! - bad!), and so rather than requiring clients to catch it, we wrap it in a ParseException. (The original Error's are thrown in TregexParserTokenManager.)

Parameters:
tregex - The pattern to parse
Returns:
A new TregexPattern object based on this string
Throws:
ParseException - If the Tregex expression is syntactically invalid


Stanford NLP Group