Package opennlp.tools.parser.lang.es
Class AncoraSpanishHeadRules
- java.lang.Object
-
- opennlp.tools.parser.lang.es.AncoraSpanishHeadRules
-
- All Implemented Interfaces:
GapLabeler
,HeadRules
,SerializableArtifact
public class AncoraSpanishHeadRules extends Object implements HeadRules, GapLabeler, SerializableArtifact
Class for storing the Ancora Spanish head rules associated with parsing. In this class headrules for noun phrases are specified. The rest of the rules are in opennlp-tools/lang/es/parser/es-head-rules NOTE: This class has been adapted from opennlp.tools.parser.lang.en.HeadRules The main change is the constituents search direction in the first for loop. Note also the change in the return of the getHead() method: In the lang.en.HeadRules class: return constituents[ci].getHead(); Now: return constituents[ci]; Other changes include removal of deprecated methods.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AncoraSpanishHeadRules.HeadRulesSerializer
-
Constructor Summary
Constructors Constructor Description AncoraSpanishHeadRules(Reader rulesReader)
Creates a new set of head rules based on the specified reader.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
Class<?>
getArtifactSerializerClass()
Retrieves the class which can serialize and recreate this artifact.Parse
getHead(Parse[] constituents, String type)
Retrieves the headconstituent
for the specified constituents of giventype
.Set<String>
getPunctuationTags()
int
hashCode()
void
labelGaps(Stack<Constituent> stack)
Labelsconstituents
found in thestack
with gap labels if appropriate.void
serialize(Writer writer)
Serializes the head rules via aWriter
in a format suitable for loading the head rules again.
-
-
-
Constructor Detail
-
AncoraSpanishHeadRules
public AncoraSpanishHeadRules(Reader rulesReader) throws IOException
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 Detail
-
getPunctuationTags
public Set<String> getPunctuationTags()
- Specified by:
getPunctuationTags
in interfaceHeadRules
- Returns:
- Retrieves the set of punctuation tags. Attachment decisions for these tags will not be modeled.
-
getHead
public Parse getHead(Parse[] constituents, String type)
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
public void labelGaps(Stack<Constituent> stack)
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
public void serialize(Writer writer) throws IOException
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.
-
getArtifactSerializerClass
public Class<?> 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.
-
-