public abstract class NamedRegexDetector extends RegexNamedEntityFactory
RegexNamedEntityFactory in cases where
NamedEntities do use a single Token.Type
NamedEntities do use the NamedPattern#getName() as Token#getValue()
loadPatterns() Method that
is called once and is expected to provide the list of Regex patterns.
The acceptMatch(String, MatchResult) provides a callback that allows to filter out
unwanted matches. The default implementation will filter out all
blank matches
RegexNamedEntityFactory.NamedPatternlog| Constructor and Description |
|---|
NamedRegexDetector(NerTag type) |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
acceptMatch(String name,
MatchResult match)
If the match for the Pattern with the parsed name should be accepted.
|
protected RegexNerProcessor.NamedEntity |
createNamedEntity(String name,
MatchResult match)
Creates a token for the parsed
MatchResult originating from the
RegexNamedEntityFactory.NamedPattern with the parsed name |
protected List<RegexNamedEntityFactory.NamedPattern> |
getRegexes(SpanCollection section,
String lang)
Getter for the
RegexNamedEntityFactory.NamedPattern to be used by the RegexNerProcessor |
NerTag |
getType() |
void |
init() |
protected abstract Map<String,List<RegexNamedEntityFactory.NamedPattern>> |
loadPatterns() |
processpublic NamedRegexDetector(NerTag type)
public NerTag getType()
@PostConstruct public final void init() throws IOException
IOExceptionprotected abstract Map<String,List<RegexNamedEntityFactory.NamedPattern>> loadPatterns() throws IOException
IOExceptionprotected List<RegexNamedEntityFactory.NamedPattern> getRegexes(SpanCollection section, String lang)
RegexNamedEntityFactoryRegexNamedEntityFactory.NamedPattern to be used by the RegexNerProcessorgetRegexes in class RegexNamedEntityFactorysection - the section of an AnalyzedText to be analyzed with the
returned patternslang - the language of the parsed text sectionRegexNamedEntityFactory.NamedPattern or an empty list if noneprotected RegexNerProcessor.NamedEntity createNamedEntity(String name, MatchResult match)
RegexNamedEntityFactoryMatchResult originating from the
RegexNamedEntityFactory.NamedPattern with the parsed namecreateNamedEntity in class RegexNamedEntityFactoryname - the name of the RegexNamedEntityFactory.NamedPatternmatch - the MatchResultRegexNerProcessor.NamedEntity or null if no Token was created.protected boolean acceptMatch(String name, MatchResult match)
MatchResult.group()name - the name of the patternmatch - the matchtrue if a Token should be created for this match. Otherwise falseCopyright © 2016–2017 Redlink GmbH. All rights reserved.