Package opennlp.tools.namefind
Class NameSample
java.lang.Object
opennlp.tools.namefind.NameSample
- All Implemented Interfaces:
Serializable
,Sample
Encapsulates names for a single unit of text.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The default type value when there is no type in training data. -
Constructor Summary
ConstructorDescriptionNameSample
(String[] sentence, Span[] names, boolean clearAdaptiveData) Initializes aNameSample
instance with given parameters.NameSample
(String[] sentence, Span[] names, String[][] additionalContext, boolean clearAdaptiveData) Initializes aNameSample
instance with given parameters.NameSample
(String id, String[] sentence, Span[] names, String[][] additionalContext, boolean clearAdaptiveData) Initializes aNameSample
instance with given parameters. -
Method Summary
Modifier and TypeMethodDescriptionboolean
String[][]
getId()
Span[]
getNames()
String[]
int
hashCode()
boolean
static NameSample
Parses given input into aNameSample
.static NameSample
Parses given input into aNameSample
.toString()
-
Field Details
-
DEFAULT_TYPE
The default type value when there is no type in training data.- See Also:
-
-
Constructor Details
-
NameSample
public NameSample(String id, String[] sentence, Span[] names, String[][] additionalContext, boolean clearAdaptiveData) Initializes aNameSample
instance with given parameters.- Parameters:
id
- The identifier to use.sentence
- The tokens representing a training sentence. Must not benull
.names
- Thenames
to use.additionalContext
- Additional context in a 2-dimensional array.clearAdaptiveData
- Iftrue
the adaptive data of the feature generators is cleared.- Throws:
RuntimeException
- Thrown if name spans are overlapping.
-
NameSample
public NameSample(String[] sentence, Span[] names, String[][] additionalContext, boolean clearAdaptiveData) Initializes aNameSample
instance with given parameters.- Parameters:
sentence
- The tokens representing a sentence. Must not benull
.names
- Thenames
to use.additionalContext
- Additional context in a 2-dimensional array.clearAdaptiveData
- Iftrue
the adaptive data of the feature generators is cleared.- Throws:
RuntimeException
- Thrown if name spans are overlapping.
-
NameSample
Initializes aNameSample
instance with given parameters.- Parameters:
sentence
- The tokens representing a sentence. Must not benull
.names
- Thenames
to use.clearAdaptiveData
- Iftrue
the adaptive data of the feature generators is cleared.- Throws:
RuntimeException
- Thrown if name spans are overlapping.
-
-
Method Details
-
getId
- Returns:
- Retrieves the current identifier. May be
null
.
-
getSentence
- Returns:
- Retrieves the sentence in tokenized form.
-
getNames
- Returns:
- Retrieves the
names
.
-
getAdditionalContext
- Returns:
- Retrieves additional context. May be
null
.
-
isClearAdaptiveDataSet
public boolean isClearAdaptiveDataSet()- Returns:
true
if the adaptive data of the feature generators are cleared,false
otherwise.
-
hashCode
public int hashCode() -
equals
-
toString
-
parse
Parses given input into aNameSample
.- Parameters:
taggedTokens
- The input data to parse.clearAdaptiveData
-true
if the adaptive data of the feature generators should be cleared,false
otherwise.- Returns:
- A
NameSample
instance resulting from the parsing. - Throws:
IOException
- Thrown if IO errors occurred during parsing.
-
parse
public static NameSample parse(String taggedTokens, String defaultType, boolean clearAdaptiveData) throws IOException Parses given input into aNameSample
.- Parameters:
taggedTokens
- The input data to parse.defaultType
- The type to set by default.clearAdaptiveData
-true
if the adaptive data of the feature generators should be cleared,false
otherwise.- Returns:
- A
NameSample
instance resulting from the parsing. - Throws:
IOException
- Thrown if IO errors occurred during parsing.
-