Package opennlp.tools.parser.lang.en

# Class HeadRules

java.lang.Object
opennlp.tools.parser.lang.en.HeadRules

All Implemented Interfaces:
  `opennlp.tools.parser.GapLabeler`, `opennlp.tools.parser.HeadRules`, `opennlp.tools.util.model.SerializableArtifact`

public class HeadRules extends Object implements opennlp.tools.parser.HeadRules, opennlp.tools.parser.GapLabeler, opennlp.tools.util.model.SerializableArtifact
Class for storing the English `HeadRules` associated with parsing.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `HeadRules.HeadRulesSerializer`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `HeadRules(Reader rulesReader)`
  Creates a new set of head rules based on the specified reader.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `equals(Object obj)`
  `Class<?>`
  `getArtifactSerializerClass()`
  `opennlp.tools.parser.Parse`
  `getHead(opennlp.tools.parser.Parse[] constituents, String type)`
  `Set<String>`
  `getPunctuationTags()`
  `int`
  `hashCode()`
  `void`
  `labelGaps(Stack<opennlp.tools.parser.Constituent> stack)`
  `void`
  `serialize(Writer writer)`
  Serializes the head rules via a `Writer` in a format suitable for loading the head rules again.

  ### Methods inherited from class java.lang.Object

  `getClass, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### HeadRules

    public HeadRules(Reader rulesReader) throws IOException
    Creates a new set of head rules based on the specified reader.
    Parameters:
      `rulesReader` - A `Reader` for a head rules file.
    Throws:
      `IOException` - Thrown f the head rules reader can not be read.

- ## Method Details

  - ### getPunctuationTags

    public Set<String> getPunctuationTags()
    Specified by:
      `getPunctuationTags` in interface `opennlp.tools.parser.HeadRules`

  - ### getHead

    public opennlp.tools.parser.Parse getHead(opennlp.tools.parser.Parse[] constituents, String type)
    Specified by:
      `getHead` in interface `opennlp.tools.parser.HeadRules`

  - ### labelGaps

    public void labelGaps(Stack<opennlp.tools.parser.Constituent> stack)
    Specified by:
      `labelGaps` in interface `opennlp.tools.parser.GapLabeler`

  - ### serialize

    public void serialize(Writer writer) throws IOException
    Serializes the head rules via a `Writer` 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` - The `Writer` to write the head rules to.
    Throws:
      `IOException` - Thrown if IO errors occurred during write operation.

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`

  - ### equals

    public boolean equals(Object obj)
    Overrides:
      `equals` in class `Object`

  - ### getArtifactSerializerClass

    public Class<?> getArtifactSerializerClass()
    Specified by:
      `getArtifactSerializerClass` in interface `opennlp.tools.util.model.SerializableArtifact`