Package opennlp.tools.namefind
Class NameFinderEventStream
- java.lang.Object
-
- opennlp.tools.util.AbstractEventStream<NameSample>
-
- opennlp.tools.namefind.NameFinderEventStream
-
- All Implemented Interfaces:
AutoCloseable,ObjectStream<Event>
public class NameFinderEventStream extends AbstractEventStream<NameSample>
Class for creating an event stream out of data files for training anTokenNameFinder.
-
-
Constructor Summary
Constructors Constructor Description NameFinderEventStream(ObjectStream<NameSample> dataStream, String type, NameContextGenerator contextGenerator, SequenceCodec<String> codec)
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static String[][]additionalContext(String[] tokens, Map<String,String> prevMap)Generated previous decision features for each token based on contents of the specifiedprevMap.static List<Event>generateEvents(String[] sentence, String[] outcomes, NameContextGenerator cg)Generateseventsfor each token in asentencewith the specifiedoutcomesusing the specifiedNameContextGenerator.static String[]generateOutcomes(Span[] names, String type, int length)Deprecated.use theBioCodecimplementation of the SequenceValidator instead!-
Methods inherited from class opennlp.tools.util.AbstractEventStream
close, read, reset
-
-
-
-
Constructor Detail
-
NameFinderEventStream
public NameFinderEventStream(ObjectStream<NameSample> dataStream, String type, NameContextGenerator contextGenerator, SequenceCodec<String> codec)
- Parameters:
dataStream- Thedata streamof events.type-nullor overrides the type parameter in the provided samples.contextGenerator- TheNameContextGeneratorused to generate features for the event stream.codec- TheSequenceCodecto use.
-
-
Method Detail
-
generateOutcomes
@Deprecated public static String[] generateOutcomes(Span[] names, String type, int length)
Deprecated.use theBioCodecimplementation of the SequenceValidator instead!Generates the name tag outcomes (start,continue,other) for each token in a sentence with the specifiedlengthusing the specifiednames.- Parameters:
names- Tokenspansfor each of the names.type-nullor overrides the type parameter in the provided sampleslength- The length of the sentence.- Returns:
- An array of
start,continue,otheroutcomes based on the specified names and sentencelength.
-
generateEvents
public static List<Event> generateEvents(String[] sentence, String[] outcomes, NameContextGenerator cg)
Generateseventsfor each token in asentencewith the specifiedoutcomesusing the specifiedNameContextGenerator.- Parameters:
sentence- Token representing a sentence.outcomes- An array of outcomes.cg- TheNameContextGeneratorto use.- Returns:
- A list of
eventsgenerated.
-
additionalContext
public static String[][] additionalContext(String[] tokens, Map<String,String> prevMap)
Generated previous decision features for each token based on contents of the specifiedprevMap.- Parameters:
tokens- The token for which the context is generated.prevMap- A mapping of tokens to their previous decisions.- Returns:
- A 2-dimensional array with additional context with features for each token.
-
-