Package opennlp.tools.parser.lang.en
Class HeadRules
java.lang.Object
opennlp.tools.parser.lang.en.HeadRules
- All Implemented Interfaces:
GapLabeler
,HeadRules
,SerializableArtifact
Class for storing the English
HeadRules
associated with parsing.-
Nested Class Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Class<?>
Retrieves the class which can serialize and recreate this artifact.Retrieves the headconstituent
for the specified constituents of giventype
.int
hashCode()
void
labelGaps
(Stack<Constituent> stack) Labelsconstituents
found in thestack
with gap labels if appropriate.void
Serializes the head rules via aWriter
in a format suitable for loading the head rules again.
-
Constructor Details
-
HeadRules
Deprecated.UseHeadRules(Reader)
instead.Creates a new set of head rules based on the specifiedruleFile
.- Parameters:
ruleFile
- A string representation for a head rules file.- Throws:
IOException
- Thrown if the head rules file can not be read.
-
HeadRules
Creates a new set of head rules based on the specified reader.- Parameters:
rulesReader
- AReader
for a head rules file.- Throws:
IOException
- Thrown f the head rules reader can not be read.
-
-
Method Details
-
getPunctuationTags
- Specified by:
getPunctuationTags
in interfaceHeadRules
- Returns:
- Retrieves the set of punctuation tags. Attachment decisions for these tags will not be modeled.
-
getHead
Description copied from interface:HeadRules
Retrieves the headconstituent
for the specified constituents of giventype
.- Specified by:
getHead
in interfaceHeadRules
- Parameters:
constituents
- Theconstituents
which make up a constituent of the specifiedtype
.type
- The type of a constituent which is made up of theconstituents
.- Returns:
- The
constituent
which represents the head.
-
labelGaps
Description copied from interface:GapLabeler
Labelsconstituents
found in thestack
with gap labels if appropriate.- Specified by:
labelGaps
in interfaceGapLabeler
- Parameters:
stack
- TheStack
of un-completedconstituents
.
-
serialize
Serializes the head rules via aWriter
in a format suitable for loading the head rules again. The encoding must be taken into account while working with the writer and reader.Once the entries have been written, the
writer
is flushed.Note: The
writer
remains open after this method returns.- Parameters:
writer
- TheWriter
to write the head rules to.- Throws:
IOException
- Thrown if IO errors occurred during write operation.
-
hashCode
public int hashCode() -
equals
-
getArtifactSerializerClass
Description copied from interface:SerializableArtifact
Retrieves the class which can serialize and recreate this artifact.Note: The serializer class must have a
public zero argument constructor
or an exception is thrown during model serialization/loading.- Specified by:
getArtifactSerializerClass
in interfaceSerializableArtifact
- Returns:
- The corresponding
ArtifactSerializer
class.
-
HeadRules(Reader)
instead.