public class CoreMapExpressionExtractor<T extends MatchedExpression> extends Object
Represents a list of assignment and extraction rules over sequence patterns.
See SequenceMatchRules for syntax of rules.
Assignment rules are used to assign a value to a variable for later use in extraction rules or for expansions in patterns.
Extraction rules are used to extract text/tokens matching regular expressions. Extraction rules are grouped into stages, with each stage consisting of the following:
CoreMap.SequenceMatchRules| Modifier and Type | Class and Description |
|---|---|
static class |
CoreMapExpressionExtractor.Stage<T>
Describes one stage of extraction.
|
| Constructor and Description |
|---|
CoreMapExpressionExtractor()
Creates an empty instance with no rules.
|
CoreMapExpressionExtractor(Env env)
Creates a default instance with the specified environment.
|
CoreMapExpressionExtractor(Env env,
List<SequenceMatchRules.Rule> rules)
Creates an instance with the specified environment and list of rules
|
| Modifier and Type | Method and Description |
|---|---|
void |
appendRules(List<SequenceMatchRules.Rule> rules)
Add specified rules to this extractor
|
Pair<List<? extends CoreMap>,List<T>> |
applyCompositeRule(SequenceMatchRules.ExtractRule<List<? extends CoreMap>,T> compositeExtractRule,
List<? extends CoreMap> merged,
List<T> matchedExpressions,
int limit) |
static CoreMapExpressionExtractor |
createExtractorFromFile(Env env,
String filename)
Creates an extractor using the specified environment, and reading the rules from the given filename.
|
static CoreMapExpressionExtractor |
createExtractorFromFiles(Env env,
List<String> filenames)
Creates an extractor using the specified environment, and reading the rules from the given filenames.
|
static CoreMapExpressionExtractor |
createExtractorFromFiles(Env env,
String... filenames)
Creates an extractor using the specified environment, and reading the rules from the given filenames
|
static CoreMapExpressionExtractor |
createExtractorFromString(Env env,
String str)
Creates an extractor using the specified environment, and reading the rules from the given string
|
List<CoreMap> |
extractCoreMaps(CoreMap annotation)
Returns list of coremaps that matches the specified rules
|
List<CoreMap> |
extractCoreMapsMergedWithTokens(CoreMap annotation)
Returns list of merged tokens and original tokens
|
List<CoreMap> |
extractCoreMapsToList(List<CoreMap> res,
CoreMap annotation) |
List<T> |
extractExpressions(CoreMap annotation) |
List<CoreMap> |
flatten(List<CoreMap> cms) |
Env |
getEnv() |
Value |
getValue(String varname) |
void |
setExtractRules(SequenceMatchRules.ExtractRule<CoreMap,T> basicExtractRule,
SequenceMatchRules.ExtractRule<List<? extends CoreMap>,T> compositeExtractRule,
java.util.function.Predicate<T> filterRule) |
void |
setLogger(Logger logger) |
public CoreMapExpressionExtractor()
public CoreMapExpressionExtractor(Env env)
env - Environment to use for binding variables and applying rulespublic CoreMapExpressionExtractor(Env env, List<SequenceMatchRules.Rule> rules)
env - Environment to use for binding variables and applying rulesrules - List of rules for this extractorpublic void appendRules(List<SequenceMatchRules.Rule> rules)
rules - public Env getEnv()
public void setLogger(Logger logger)
public void setExtractRules(SequenceMatchRules.ExtractRule<CoreMap,T> basicExtractRule, SequenceMatchRules.ExtractRule<List<? extends CoreMap>,T> compositeExtractRule, java.util.function.Predicate<T> filterRule)
public static CoreMapExpressionExtractor createExtractorFromFiles(Env env, String... filenames) throws RuntimeException
env - filenames - RuntimeExceptionpublic static CoreMapExpressionExtractor createExtractorFromFiles(Env env, List<String> filenames) throws RuntimeException
env - filenames - RuntimeExceptionpublic static CoreMapExpressionExtractor createExtractorFromFile(Env env, String filename) throws RuntimeException
env - filename - RuntimeExceptionpublic static CoreMapExpressionExtractor createExtractorFromString(Env env, String str) throws IOException, ParseException
env - str - IOException, - ParseExceptionIOExceptionParseExceptionpublic List<CoreMap> extractCoreMapsToList(List<CoreMap> res, CoreMap annotation)
public List<CoreMap> extractCoreMaps(CoreMap annotation)
annotation - public List<CoreMap> extractCoreMapsMergedWithTokens(CoreMap annotation)
annotation - public Pair<List<? extends CoreMap>,List<T>> applyCompositeRule(SequenceMatchRules.ExtractRule<List<? extends CoreMap>,T> compositeExtractRule, List<? extends CoreMap> merged, List<T> matchedExpressions, int limit)