Package opennlp.tools.namefind
Class RegexNameFinder
- java.lang.Object
-
- opennlp.tools.namefind.RegexNameFinder
-
- All Implemented Interfaces:
TokenNameFinder
public final class RegexNameFinder extends Object implements TokenNameFinder
ATokenNameFinderimplementation based on a series of regular expressions.
-
-
Constructor Summary
Constructors Constructor Description RegexNameFinder(Map<String,Pattern[]> regexMap)Initializes aRegexNameFinderinstance.RegexNameFinder(Pattern[] patterns)Deprecated.Use constructorRegexNameFinder(Pattern[], String)for single types, and/or constructorRegexNameFinder(Map)instead.RegexNameFinder(Pattern[] patterns, String type)Initializes aRegexNameFinderinstance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearAdaptiveData()Forgets all adaptive data which was collected during previous calls to one of the find methods.Span[]find(String text)Findsspanswith character indices, rather than word.Span[]find(String[] tokens)Generates name tags for the given sequence, typically a sentence, returningtoken spansfor any identified names.Pattern[]getMatchingPatterns()StringgetSpanType()voidsetMatchingPatterns(Pattern[] mPatterns)voidsetSpanType(String sType)
-
-
-
Constructor Detail
-
RegexNameFinder
public RegexNameFinder(Map<String,Pattern[]> regexMap)
Initializes aRegexNameFinderinstance.
-
RegexNameFinder
public RegexNameFinder(Pattern[] patterns, String type)
Initializes aRegexNameFinderinstance.- Parameters:
patterns- Thepatternsto use. Must not benulland not be empty.type- The type to use.- Throws:
IllegalArgumentException- Thrown ifpatternswerenullor empty.
-
RegexNameFinder
@Deprecated public RegexNameFinder(Pattern[] patterns)
Deprecated.Use constructorRegexNameFinder(Pattern[], String)for single types, and/or constructorRegexNameFinder(Map)instead.Initializes aRegexNameFinderinstance.- Parameters:
patterns- Thepatternsto use. Must not benulland not be empty.- Throws:
IllegalArgumentException- Thrown ifpatternswerenullor empty.
-
-
Method Detail
-
find
public Span[] find(String[] tokens)
Description copied from interface:TokenNameFinderGenerates name tags for the given sequence, typically a sentence, returningtoken spansfor any identified names.- Specified by:
findin interfaceTokenNameFinder- Parameters:
tokens- An array of the tokens or words of the sequence, typically a sentence.- Returns:
- An array of
spansfor each of the names identified.
-
find
public Span[] find(String text)
Findsspanswith character indices, rather than word.- Parameters:
text- The text to use.- Returns:
- A
Spanrepresenting the annotations.
-
clearAdaptiveData
public void clearAdaptiveData()
Description copied from interface:TokenNameFinderForgets all adaptive data which was collected during previous calls to one of the find methods.Note: This method should typically be called at the end of the processing of a document.
- Specified by:
clearAdaptiveDatain interfaceTokenNameFinder
-
getMatchingPatterns
public Pattern[] getMatchingPatterns()
- Returns:
- Retrieves the
matching patternsused.
-
setMatchingPatterns
public void setMatchingPatterns(Pattern[] mPatterns)
- Parameters:
mPatterns- Thematching patternsto be set.
-
-