public class CoreMapExpressionExtractor<T extends MatchedExpression>
extends java.lang.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,
java.util.List<SequenceMatchRules.Rule> rules)
Creates an instance with the specified environment and list of rules
|
Modifier and Type | Method and Description |
---|---|
void |
appendRules(java.util.List<SequenceMatchRules.Rule> rules)
Add specified rules to this extractor
|
Pair<java.util.List<? extends CoreMap>,java.util.List<T>> |
applyCompositeRule(SequenceMatchRules.ExtractRule<java.util.List<? extends CoreMap>,T> compositeExtractRule,
java.util.List<? extends CoreMap> merged,
java.util.List<T> matchedExpressions,
int limit) |
static CoreMapExpressionExtractor |
createExtractorFromFile(Env env,
java.lang.String filename)
Creates an extractor using the specified environment, and reading the rules from the given filename.
|
static CoreMapExpressionExtractor |
createExtractorFromFiles(Env env,
java.util.List<java.lang.String> filenames)
Creates an extractor using the specified environment, and reading the rules from the given filenames.
|
static CoreMapExpressionExtractor |
createExtractorFromFiles(Env env,
java.lang.String... filenames)
Creates an extractor using the specified environment, and reading the rules from the given filenames
|
static CoreMapExpressionExtractor |
createExtractorFromString(Env env,
java.lang.String str)
Creates an extractor using the specified environment, and reading the rules from the given string
|
java.util.List<CoreMap> |
extractCoreMaps(CoreMap annotation)
Returns list of coremaps that matches the specified rules
|
java.util.List<CoreMap> |
extractCoreMapsMergedWithTokens(CoreMap annotation)
Returns list of merged tokens and original tokens
|
java.util.List<CoreMap> |
extractCoreMapsToList(java.util.List<CoreMap> res,
CoreMap annotation) |
java.util.List<T> |
extractExpressions(CoreMap annotation) |
java.util.List<CoreMap> |
flatten(java.util.List<CoreMap> cms) |
Env |
getEnv() |
Value |
getValue(java.lang.String varname) |
void |
setExtractRules(SequenceMatchRules.ExtractRule<CoreMap,T> basicExtractRule,
SequenceMatchRules.ExtractRule<java.util.List<? extends CoreMap>,T> compositeExtractRule,
java.util.function.Predicate<T> filterRule) |
void |
setLogger(java.util.logging.Logger logger) |
public CoreMapExpressionExtractor()
public CoreMapExpressionExtractor(Env env)
env
- Environment to use for binding variables and applying rulespublic CoreMapExpressionExtractor(Env env, java.util.List<SequenceMatchRules.Rule> rules)
env
- Environment to use for binding variables and applying rulesrules
- List of rules for this extractorpublic void appendRules(java.util.List<SequenceMatchRules.Rule> rules)
rules
- public Env getEnv()
public void setLogger(java.util.logging.Logger logger)
public void setExtractRules(SequenceMatchRules.ExtractRule<CoreMap,T> basicExtractRule, SequenceMatchRules.ExtractRule<java.util.List<? extends CoreMap>,T> compositeExtractRule, java.util.function.Predicate<T> filterRule)
public static CoreMapExpressionExtractor createExtractorFromFiles(Env env, java.lang.String... filenames) throws java.lang.RuntimeException
env
- filenames
- java.lang.RuntimeException
public static CoreMapExpressionExtractor createExtractorFromFiles(Env env, java.util.List<java.lang.String> filenames) throws java.lang.RuntimeException
env
- filenames
- java.lang.RuntimeException
public static CoreMapExpressionExtractor createExtractorFromFile(Env env, java.lang.String filename) throws java.lang.RuntimeException
env
- filename
- java.lang.RuntimeException
public static CoreMapExpressionExtractor createExtractorFromString(Env env, java.lang.String str) throws java.io.IOException, ParseException, TokenSequenceParseException
env
- str
- IOException,
- ParseExceptionjava.io.IOException
ParseException
TokenSequenceParseException
public Value getValue(java.lang.String varname)
public java.util.List<CoreMap> extractCoreMapsToList(java.util.List<CoreMap> res, CoreMap annotation)
public java.util.List<CoreMap> extractCoreMaps(CoreMap annotation)
annotation
- public java.util.List<CoreMap> extractCoreMapsMergedWithTokens(CoreMap annotation)
annotation
- public Pair<java.util.List<? extends CoreMap>,java.util.List<T>> applyCompositeRule(SequenceMatchRules.ExtractRule<java.util.List<? extends CoreMap>,T> compositeExtractRule, java.util.List<? extends CoreMap> merged, java.util.List<T> matchedExpressions, int limit)