Package opennlp.tools.parser.lang.en
Class HeadRules
- java.lang.Object
-
- opennlp.tools.parser.lang.en.HeadRules
-
- All Implemented Interfaces:
GapLabeler,HeadRules,SerializableArtifact
public class HeadRules extends Object implements HeadRules, GapLabeler, SerializableArtifact
Class for storing the EnglishHeadRulesassociated with parsing.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classHeadRules.HeadRulesSerializer
-
Constructor Summary
Constructors Constructor Description HeadRules(Reader rulesReader)Creates a new set of head rules based on the specified reader.HeadRules(String ruleFile)Deprecated.UseHeadRules(Reader)instead.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)Class<?>getArtifactSerializerClass()Retrieves the class which can serialize and recreate this artifact.ParsegetHead(Parse[] constituents, String type)Retrieves the headconstituentfor the specified constituents of giventype.Set<String>getPunctuationTags()inthashCode()voidlabelGaps(Stack<Constituent> stack)Labelsconstituentsfound in thestackwith gap labels if appropriate.voidserialize(Writer writer)Serializes the head rules via aWriterin a format suitable for loading the head rules again.
-
-
-
Constructor Detail
-
HeadRules
@Deprecated public HeadRules(String ruleFile) throws IOException
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
public HeadRules(Reader rulesReader) throws IOException
Creates a new set of head rules based on the specified reader.- Parameters:
rulesReader- AReaderfor 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:
getPunctuationTagsin 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:HeadRulesRetrieves the headconstituentfor the specified constituents of giventype.- Specified by:
getHeadin interfaceHeadRules- Parameters:
constituents- Theconstituentswhich make up a constituent of the specifiedtype.type- The type of a constituent which is made up of theconstituents.- Returns:
- The
constituentwhich represents the head.
-
labelGaps
public void labelGaps(Stack<Constituent> stack)
Description copied from interface:GapLabelerLabelsconstituentsfound in thestackwith gap labels if appropriate.- Specified by:
labelGapsin interfaceGapLabeler- Parameters:
stack- TheStackof un-completedconstituents.
-
serialize
public void serialize(Writer writer) throws IOException
Serializes the head rules via aWriterin 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
writeris flushed.Note: The
writerremains open after this method returns.- Parameters:
writer- TheWriterto write the head rules to.- Throws:
IOException- Thrown if IO errors occurred during write operation.
-
getArtifactSerializerClass
public Class<?> getArtifactSerializerClass()
Description copied from interface:SerializableArtifactRetrieves the class which can serialize and recreate this artifact.Note: The serializer class must have a
public zero argument constructoror an exception is thrown during model serialization/loading.- Specified by:
getArtifactSerializerClassin interfaceSerializableArtifact- Returns:
- The corresponding
ArtifactSerializerclass.
-
-