public class CoreMapExpressionExtractor<T extends MatchedExpression> extends 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,
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.
|
static CoreMapExpressionExtractor |
createExtractorFromFile(Env env,
String filename)
Creates an extractor using the specified environment, and reading the rules from the given filename.
|
static <M extends MatchedExpression> |
createExtractorFromFiles(Env env,
List<String> filenames)
Creates an extractor using the specified environment, and reading the rules from the given filenames.
|
static <M extends MatchedExpression> |
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<T> |
extractExpressions(CoreMap annotation) |
List<CoreMap> |
flatten(List<CoreMap> cms) |
Env |
getEnv() |
Value |
getValue(String varname) |
CoreMapExpressionExtractor |
keepTemporaryTags()
Keeps the temporary tags on the sentence after extraction has finished.
|
void |
setExtractRules(SequenceMatchRules.ExtractRule<CoreMap,T> basicExtractRule,
SequenceMatchRules.ExtractRule<List<? extends CoreMap>,T> compositeExtractRule,
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, 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 setExtractRules(SequenceMatchRules.ExtractRule<CoreMap,T> basicExtractRule, SequenceMatchRules.ExtractRule<List<? extends CoreMap>,T> compositeExtractRule, Predicate<T> filterRule)
public static <M extends MatchedExpression> CoreMapExpressionExtractor<M> createExtractorFromFiles(Env env, String... filenames) throws RuntimeException
env
- filenames
- RuntimeException
public static <M extends MatchedExpression> CoreMapExpressionExtractor<M> createExtractorFromFiles(Env env, List<String> filenames) throws RuntimeException
env
- filenames
- RuntimeException
public static CoreMapExpressionExtractor createExtractorFromFile(Env env, String filename) throws RuntimeException
env
- filename
- RuntimeException
public static CoreMapExpressionExtractor createExtractorFromString(Env env, String str) throws IOException, ParseException, TokenSequenceParseException
env
- str
- IOException,
- ParseExceptionIOException
ParseException
TokenSequenceParseException
public List<CoreMap> extractCoreMaps(CoreMap annotation)
annotation
- public List<CoreMap> extractCoreMapsMergedWithTokens(CoreMap annotation)
annotation
- public CoreMapExpressionExtractor keepTemporaryTags()
public static void setVerbose(boolean v)