public class TregexPatternCompiler
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static TregexPatternCompiler |
defaultCompiler |
Constructor and Description |
---|
TregexPatternCompiler() |
TregexPatternCompiler(java.util.function.Function<java.lang.String,java.lang.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,
java.util.function.Function<java.lang.String,java.lang.String> basicCatFunction)
A compiler that uses this HeadFinder and this basicCategoryFunction
|
Modifier and Type | Method and Description |
---|---|
void |
addMacro(java.lang.String original,
java.lang.String replacement)
Define a macro for rewriting a pattern in any tregex expression compiled
by this compiler.
|
TregexPattern |
compile(java.lang.String tregex)
Create a TregexPattern from this tregex string using the headFinder and
basicCat function this TregexPatternCompiler was created with.
|
public static final TregexPatternCompiler defaultCompiler
public TregexPatternCompiler()
public TregexPatternCompiler(java.util.function.Function<java.lang.String,java.lang.String> basicCatFunction)
basicCatFunction
- the function mapping Strings to Stringspublic TregexPatternCompiler(HeadFinder headFinder)
headFinder
- the HeadFinderpublic TregexPatternCompiler(HeadFinder headFinder, java.util.function.Function<java.lang.String,java.lang.String> basicCatFunction)
headFinder
- the HeadFinderbasicCatFunction
- The function mapping Strings to Stringspublic void addMacro(java.lang.String original, java.lang.String replacement)
tpc.addMacro("FINITE_BE_AUX", "/^(?i:am|is|are|was|were)$/");
original
- The String to match; becomes the first argument of a
String.replaceAll()replacement
- The replacement String; becomes the second argument
of a String.replaceAll()public TregexPattern compile(java.lang.String tregex)
tregex
- The pattern to parseTregexParseException
- If the expression is syntactically invalid