public class CoreMapExpressionExtractor<T extends MatchedExpression>
extends java.lang.Object
SequenceMatchRules
for the 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.
|
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 <M extends MatchedExpression> |
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 <M extends MatchedExpression> |
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<T> |
extractExpressions(CoreMap annotation) |
java.util.List<CoreMap> |
flatten(java.util.List<CoreMap> cms) |
Env |
getEnv() |
Value |
getValue(java.lang.String varname) |
CoreMapExpressionExtractor |
keepTemporaryTags()
Keeps the temporary tags on the sentence after extraction has finished.
|
void |
setExtractRules(SequenceMatchRules.ExtractRule<CoreMap,T> basicExtractRule,
SequenceMatchRules.ExtractRule<java.util.List<? extends CoreMap>,T> compositeExtractRule,
java.util.function.Predicate<T> filterRule) |
static void |
setVerbose(boolean v) |
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 setExtractRules(SequenceMatchRules.ExtractRule<CoreMap,T> basicExtractRule, SequenceMatchRules.ExtractRule<java.util.List<? extends CoreMap>,T> compositeExtractRule, java.util.function.Predicate<T> filterRule)
public static <M extends MatchedExpression> CoreMapExpressionExtractor<M> createExtractorFromFiles(Env env, java.lang.String... filenames) throws java.lang.RuntimeException
env
- filenames
- java.lang.RuntimeException
public static <M extends MatchedExpression> CoreMapExpressionExtractor<M> 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> extractCoreMaps(CoreMap annotation)
annotation
- public java.util.List<CoreMap> extractCoreMapsMergedWithTokens(CoreMap annotation)
annotation
- public CoreMapExpressionExtractor keepTemporaryTags()
public static void setVerbose(boolean v)