Package opennlp.tools.namefind
Class RegexNameFinder
java.lang.Object
opennlp.tools.namefind.RegexNameFinder
- All Implemented Interfaces:
TokenNameFinder
A
TokenNameFinder implementation based on a series of regular expressions.-
Constructor Summary
ConstructorsConstructorDescriptionRegexNameFinder(Map<String, Pattern[]> regexMap) Initializes aRegexNameFinderinstance.RegexNameFinder(Pattern[] patterns) Deprecated.RegexNameFinder(Pattern[] patterns, String type) Initializes aRegexNameFinderinstance. -
Method Summary
Modifier and TypeMethodDescriptionvoidForgets all adaptive data which was collected during previous calls to one of the find methods.Span[]Findsspanswith character indices, rather than word.Span[]Generates name tags for the given sequence, typically a sentence, returningtoken spansfor any identified names.Pattern[]voidsetMatchingPatterns(Pattern[] mPatterns) voidsetSpanType(String sType)
-
Constructor Details
-
RegexNameFinder
Initializes aRegexNameFinderinstance. -
RegexNameFinder
Initializes aRegexNameFinderinstance.- Parameters:
patterns- Thepatternsto use. Must not benulland not be empty.type- The type to use.- Throws:
IllegalArgumentException- Thrown ifpatternswerenullor empty.
-
RegexNameFinder
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 Details
-
find
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
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
- Returns:
- Retrieves the
matching patternsused.
-
setMatchingPatterns
- Parameters:
mPatterns- Thematching patternsto be set.
-
getSpanType
- Returns:
- Retrieves the
Spantype used.
-
setSpanType
- Parameters:
sType- Sets a (different)Spantype.
-
RegexNameFinder(Pattern[], String)for single types, and/or constructorRegexNameFinder(Map)instead.