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
ConstructorDescriptionRegexNameFinder
(Map<String, Pattern[]> regexMap) Initializes aRegexNameFinder
instance.RegexNameFinder
(Pattern[] patterns, String type) Initializes aRegexNameFinder
instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Forgets all adaptive data which was collected during previous calls to one of the find methods.Span[]
Findsspans
with character indices, rather than word.Span[]
Generates name tags for the given sequence, typically a sentence, returningtoken spans
for any identified names.Pattern[]
void
setMatchingPatterns
(Pattern[] mPatterns) void
setSpanType
(String sType)
-
Constructor Details
-
RegexNameFinder
Initializes aRegexNameFinder
instance. -
RegexNameFinder
Initializes aRegexNameFinder
instance.- Parameters:
patterns
- Thepatterns
to use. Must not benull
and not be empty.type
- The type to use.- Throws:
IllegalArgumentException
- Thrown ifpatterns
werenull
or empty.
-
-
Method Details
-
find
Description copied from interface:TokenNameFinder
Generates name tags for the given sequence, typically a sentence, returningtoken spans
for any identified names.- Specified by:
find
in interfaceTokenNameFinder
- Parameters:
tokens
- An array of the tokens or words of the sequence, typically a sentence.- Returns:
- An array of
spans
for each of the names identified.
-
find
Findsspans
with character indices, rather than word.- Parameters:
text
- The text to use.- Returns:
- A
Span
representing the annotations.
-
clearAdaptiveData
public void clearAdaptiveData()Description copied from interface:TokenNameFinder
Forgets 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:
clearAdaptiveData
in interfaceTokenNameFinder
-
getMatchingPatterns
- Returns:
- Retrieves the
matching patterns
used.
-
setMatchingPatterns
- Parameters:
mPatterns
- Thematching patterns
to be set.
-
getSpanType
- Returns:
- Retrieves the
Span
type used.
-
setSpanType
- Parameters:
sType
- Sets a (different)Span
type.
-