Package opennlp.tools.formats
Class GermEval2014NameSampleStream
java.lang.Object
opennlp.tools.formats.GermEval2014NameSampleStream
- All Implemented Interfaces:
AutoCloseable,ObjectStream<NameSample>
@Internal
public class GermEval2014NameSampleStream
extends Object
implements ObjectStream<NameSample>
Parser for the GermEval 2014 Named Entity Recognition Shared Task data.
The data is in a tab-separated format with four columns:
- Token index (1-based per sentence)
- Token text
- Outer named entity tag (IOB2 scheme)
- Nested/embedded named entity tag (IOB2 scheme)
# mark document boundaries and contain
source URL and date metadata. Blank lines separate sentences.
The data uses four main entity types: Person (PER), Location (LOC),
Organization (ORG) and Other (OTH), with additional deriv and
part suffixes for derived forms and name parts respectively.
Since NameSample does not support overlapping spans, this stream
requires selecting either the outer or
inner annotation layer via a GermEval2014NameSampleStream.NerLayer parameter.
Data can be found on this web site.
Note: Do not use this class, internal use only!
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumSelects which NER annotation layer to read from the GermEval 2014 data. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intprivate final GermEval2014NameSampleStream.NerLayerprivate final ObjectStream<String> private final int -
Constructor Summary
ConstructorsConstructorDescriptionGermEval2014NameSampleStream(InputStreamFactory in, int types, GermEval2014NameSampleStream.NerLayer layer) Initializes aGermEval2014NameSampleStream.GermEval2014NameSampleStream(ObjectStream<String> lineStream, int types, GermEval2014NameSampleStream.NerLayer layer) Initializes aGermEval2014NameSampleStream. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes theObjectStreamand releases all allocated resources.convertTagsToSpans(List<String> tags) (package private) static Spanprivate booleanisTypeEnabled(String tag) private static StringmapTagToType(String tag) read()Returns the nextObjectStreamobject.voidreset()Repositions the stream at the beginning and the previously seen object sequence will be repeated exactly.
-
Field Details
-
GENERATE_PERSON_ENTITIES
public static final int GENERATE_PERSON_ENTITIES- See Also:
-
GENERATE_ORGANIZATION_ENTITIES
public static final int GENERATE_ORGANIZATION_ENTITIES- See Also:
-
GENERATE_LOCATION_ENTITIES
public static final int GENERATE_LOCATION_ENTITIES- See Also:
-
GENERATE_MISC_ENTITIES
public static final int GENERATE_MISC_ENTITIES- See Also:
-
lineStream
-
types
private final int types -
layer
-
-
Constructor Details
-
GermEval2014NameSampleStream
public GermEval2014NameSampleStream(ObjectStream<String> lineStream, int types, GermEval2014NameSampleStream.NerLayer layer) Initializes aGermEval2014NameSampleStream.- Parameters:
lineStream- AnObjectStreamover the lines in the GermEval 2014 data file.types- The entity types to include in the Name Sample object stream.layer- TheGermEval2014NameSampleStream.NerLayerto read.
-
GermEval2014NameSampleStream
public GermEval2014NameSampleStream(InputStreamFactory in, int types, GermEval2014NameSampleStream.NerLayer layer) throws IOException Initializes aGermEval2014NameSampleStream.- Parameters:
in- TheInputStreamFactoryfor the input file.types- The entity types to include in the Name Sample object stream.layer- TheGermEval2014NameSampleStream.NerLayerto read.- Throws:
IOException- Thrown if IO errors occurred.
-
-
Method Details
-
extract
- Throws:
InvalidFormatException
-
mapTagToType
- Throws:
InvalidFormatException
-
isTypeEnabled
-
convertTagsToSpans
- Throws:
IOException
-
read
Description copied from interface:ObjectStreamReturns the nextObjectStreamobject. Calling this method repeatedly until it returnsnullwill return each object from the underlying source exactly once.- Specified by:
readin interfaceObjectStream<NameSample>- Returns:
- The next object or
nullto signal that the stream is exhausted. - Throws:
IOException- Thrown if there is an error during reading.
-
reset
Description copied from interface:ObjectStreamRepositions the stream at the beginning and the previously seen object sequence will be repeated exactly. This method can be used to re-read the stream if multiple passes over the objects are required.The implementation of this method is optional.
- Specified by:
resetin interfaceObjectStream<NameSample>- Throws:
IOException- Thrown if there is an error during resetting the stream.UnsupportedOperationException- Thrown if thereset()is not supported. By default, this is the case.
-
close
Description copied from interface:ObjectStreamCloses theObjectStreamand releases all allocated resources. After close was called, it's not allowed to callObjectStream.read()orObjectStream.reset().- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceObjectStream<NameSample>- Throws:
IOException- Thrown if there is an error during closing the stream.
-