Package opennlp.tools.tokenize
Class TokSpanEventStream
- All Implemented Interfaces:
AutoCloseable,ObjectStream<Event>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AlphanumericCheckprivate final TokenContextGeneratorprivate static final org.slf4j.Loggerprivate final boolean -
Constructor Summary
ConstructorsConstructorDescriptionTokSpanEventStream(ObjectStream<TokenSample> tokenSamples, boolean skipAlphaNumerics) Initializes a new event stream based on the data stream using aTokenContextGeneratorthat relies on aDefaultTokenContextGenerator.TokSpanEventStream(ObjectStream<TokenSample> tokenSamples, boolean skipAlphaNumerics, Pattern alphaNumeric, TokenContextGenerator cg) Deprecated, for removal: This API element is subject to removal in a future version.TokSpanEventStream(ObjectStream<TokenSample> tokenSamples, boolean skipAlphaNumerics, AlphanumericCheck alphanumeric, TokenContextGenerator cg) Initializes a new event stream with the check that decides which candidate tokens count as alphanumeric.TokSpanEventStream(ObjectStream<TokenSample> tokenSamples, boolean skipAlphaNumerics, TokenContextGenerator cg) Initializes a new event stream based on the data stream using aTokenContextGeneratorandFactory.DEFAULT_CHARACTER_POLICY.TokSpanEventStream(ObjectStream<TokenSample> tokenSamples, boolean skipAlphaNumerics, TokenizerCharacterPolicy characterPolicy, TokenContextGenerator cg) Initializes a new event stream based on the data stream using aTokenContextGenerator. -
Method Summary
Modifier and TypeMethodDescriptionprivate static AlphanumericCheckReturns the check for a deprecated alphanumeric pattern.createEvents(TokenSample tokenSample) Adds training events to the event stream for each of the specifiedsample.Methods inherited from class opennlp.tools.util.AbstractEventStream
close, read, reset
-
Field Details
-
logger
private static final org.slf4j.Logger logger -
cg
-
skipAlphaNumerics
private final boolean skipAlphaNumerics -
alphanumeric
-
-
Constructor Details
-
TokSpanEventStream
public TokSpanEventStream(ObjectStream<TokenSample> tokenSamples, boolean skipAlphaNumerics, TokenizerCharacterPolicy characterPolicy, TokenContextGenerator cg) Initializes a new event stream based on the data stream using aTokenContextGenerator.- Parameters:
tokenSamples- Thedata streamfor this event stream.skipAlphaNumerics- Whether alphanumerics are skipped, or not.characterPolicy- TheTokenizerCharacterPolicythat decides which candidate tokens count as alphanumeric. Must not benull.cg- ATokenContextGeneratorwhich should be used for the event streamd.- Throws:
IllegalArgumentException- Thrown ifcharacterPolicyisnull.
-
TokSpanEventStream
@Deprecated(since="3.0.0", forRemoval=true) @SuppressForbidden("user-supplied alphanumeric pattern, kept for the deprecated API") public TokSpanEventStream(ObjectStream<TokenSample> tokenSamples, boolean skipAlphaNumerics, Pattern alphaNumeric, TokenContextGenerator cg) Deprecated, for removal: This API element is subject to removal in a future version.UseTokSpanEventStream(ObjectStream, boolean, TokenizerCharacterPolicy, TokenContextGenerator). This constructor will be removed in 4.0.Initializes a new event stream that decides which candidate tokens count as alphanumeric with a regular expression.- Parameters:
tokenSamples- Thedata streamfor this event stream.skipAlphaNumerics- Whether alphanumerics are skipped, or not.alphaNumeric- A custom alphanumericPattern, ornullforFactory.DEFAULT_CHARACTER_POLICY.cg- ATokenContextGeneratorwhich should be used for the event streamd.
-
TokSpanEventStream
TokSpanEventStream(ObjectStream<TokenSample> tokenSamples, boolean skipAlphaNumerics, AlphanumericCheck alphanumeric, TokenContextGenerator cg) Initializes a new event stream with the check that decides which candidate tokens count as alphanumeric.- Parameters:
tokenSamples- Thedata streamfor this event stream.skipAlphaNumerics- Whether alphanumerics are skipped, or not.alphanumeric- The check for alphanumeric candidate tokens. Must not benull.cg- ATokenContextGeneratorwhich should be used for the event streamd.
-
TokSpanEventStream
public TokSpanEventStream(ObjectStream<TokenSample> tokenSamples, boolean skipAlphaNumerics, TokenContextGenerator cg) Initializes a new event stream based on the data stream using aTokenContextGeneratorandFactory.DEFAULT_CHARACTER_POLICY.- Parameters:
tokenSamples- Thedata streamfor this event stream.skipAlphaNumerics- Whether alphanumerics are skipped, or not.cg- ATokenContextGeneratorwhich should be used for the event streamd.
-
TokSpanEventStream
Initializes a new event stream based on the data stream using aTokenContextGeneratorthat relies on aDefaultTokenContextGenerator.- Parameters:
tokenSamples- Thedata streamfor this event stream.skipAlphaNumerics- Whether alphanumerics are skipped, or not.
-
-
Method Details
-
checkOf
@SuppressForbidden("user-supplied alphanumeric pattern, kept for the deprecated API") private static AlphanumericCheck checkOf(Pattern alphaNumeric) Returns the check for a deprecated alphanumeric pattern.- Parameters:
alphaNumeric- A custom alphanumericPattern, ornullforFactory.DEFAULT_CHARACTER_POLICY.- Returns:
- the check for a deprecated alphanumeric pattern
-
createEvents
Adds training events to the event stream for each of the specifiedsample.- Specified by:
createEventsin classAbstractEventStream<TokenSample>- Parameters:
tokenSample- character offsets into the specified text.- Returns:
- An
Iteratorfor texteventsrepresenting thetokenSample.
-
TokSpanEventStream(ObjectStream, boolean, TokenizerCharacterPolicy, TokenContextGenerator).