Package opennlp.tools.namefind
Class BioCodec
java.lang.Object
opennlp.tools.namefind.BioCodec
- All Implemented Interfaces:
SequenceCodec<String>
The default
SequenceCodec implementation according to the BIO scheme:
- B: 'beginning' of a NE
- I: 'inside', the word is inside a NE
- O: 'outside', the word is a regular word outside a NE
- See Also:
-
Field Summary
FieldsFields inherited from interface opennlp.tools.util.SequenceCodec
DEFAULT_PREFIX -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanareOutcomesCompatible(String[] outcomes) Checks if theoutcomesof a model are compatible with thisSequenceCodec.Span[]String[](package private) static StringextractNameType(String outcome) Extracts the name type from an outcome such asperson-start: the text before the last hyphen, provided a non-empty run of ASCII letters, digits, or underscores follows that hyphen and the outcome holds no line terminator.private static booleanisWordChars(String outcome, int from) Tests whether the rest of an outcome is a non-empty run of ASCII letters, digits, or underscores.
-
Field Details
-
START
- See Also:
-
CONTINUE
- See Also:
-
OTHER
- See Also:
-
-
Constructor Details
-
BioCodec
public BioCodec()
-
-
Method Details
-
extractNameType
Extracts the name type from an outcome such asperson-start: the text before the last hyphen, provided a non-empty run of ASCII letters, digits, or underscores follows that hyphen and the outcome holds no line terminator.- Parameters:
outcome- The outcome label. Must not benull.- Returns:
- The name type, or
nullif the outcome has none.
-
isWordChars
Tests whether the rest of an outcome is a non-empty run of ASCII letters, digits, or underscores.- Parameters:
outcome- The outcome label.from- The offset the run starts at.- Returns:
trueif at least one character follows and all are word characters.
-
decode
Description copied from interface:SequenceCodec- Specified by:
decodein interfaceSequenceCodec<String>- Parameters:
c- A list ofSequenceCodecto decode.- Returns:
- A
Spanarray encapsulating the decoded elements inc.
-
encode
Description copied from interface:SequenceCodec- Specified by:
encodein interfaceSequenceCodec<String>- Parameters:
names- A list ofelementsto encode.length- The length to respect.- Returns:
- An array of
SequenceCodecto encode.
-
createSequenceValidator
- Specified by:
createSequenceValidatorin interfaceSequenceCodec<String>- Returns:
- A
SequenceValidatorwhich can validate a sequence ofoutcomes.
-
areOutcomesCompatible
Description copied from interface:SequenceCodecChecks if theoutcomesof a model are compatible with thisSequenceCodec.- Specified by:
areOutcomesCompatiblein interfaceSequenceCodec<String>- Parameters:
outcomes- The possible model outcomes.- Returns:
trueifoutcomesare type compatible,falseotherwise.
-