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 SummaryFieldsModifier and TypeFieldDescriptionstatic final StringThe default type value when there is no type in training data.
- 
Constructor SummaryConstructorsConstructorDescriptionNameSample(String[] sentence, Span[] names, boolean clearAdaptiveData) Initializes aNameSampleinstance with given parameters.NameSample(String[] sentence, Span[] names, String[][] additionalContext, boolean clearAdaptiveData) Initializes aNameSampleinstance with given parameters.NameSample(String id, String[] sentence, Span[] names, String[][] additionalContext, boolean clearAdaptiveData) Initializes aNameSampleinstance with given parameters.
- 
Method SummaryModifier and TypeMethodDescriptionbooleanString[][]getId()Span[]getNames()String[]inthashCode()booleanstatic NameSampleParses given input into aNameSample.static NameSampleParses given input into aNameSample.toString()
- 
Field Details- 
DEFAULT_TYPEThe default type value when there is no type in training data.- See Also:
 
 
- 
- 
Constructor Details- 
NameSamplepublic NameSample(String id, String[] sentence, Span[] names, String[][] additionalContext, boolean clearAdaptiveData) Initializes aNameSampleinstance with given parameters.- Parameters:
- id- The identifier to use.
- sentence- The tokens representing a training sentence. Must not be- null.
- names- The- namesto use.
- additionalContext- Additional context in a 2-dimensional array.
- clearAdaptiveData- If- truethe adaptive data of the feature generators is cleared.
- Throws:
- RuntimeException- Thrown if name spans are overlapping.
 
- 
NameSamplepublic NameSample(String[] sentence, Span[] names, String[][] additionalContext, boolean clearAdaptiveData) Initializes aNameSampleinstance with given parameters.- Parameters:
- sentence- The tokens representing a sentence. Must not be- null.
- names- The- namesto use.
- additionalContext- Additional context in a 2-dimensional array.
- clearAdaptiveData- If- truethe adaptive data of the feature generators is cleared.
- Throws:
- RuntimeException- Thrown if name spans are overlapping.
 
- 
NameSampleInitializes aNameSampleinstance with given parameters.- Parameters:
- sentence- The tokens representing a sentence. Must not be- null.
- names- The- namesto use.
- clearAdaptiveData- If- truethe 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.
 
- 
isClearAdaptiveDataSetpublic boolean isClearAdaptiveDataSet()- Returns:
- trueif the adaptive data of the feature generators are cleared,- falseotherwise.
 
- 
hashCodepublic int hashCode()
- 
equals
- 
toString
- 
parseParses given input into aNameSample.- Parameters:
- taggedTokens- The input data to parse.
- clearAdaptiveData-- trueif the adaptive data of the feature generators should be cleared,- falseotherwise.
- Returns:
- A NameSampleinstance resulting from the parsing.
- Throws:
- IOException- Thrown if IO errors occurred during parsing.
 
- 
parsepublic 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-- trueif the adaptive data of the feature generators should be cleared,- falseotherwise.
- Returns:
- A NameSampleinstance resulting from the parsing.
- Throws:
- IOException- Thrown if IO errors occurred during parsing.
 
 
-