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 English head rules 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.
    `HeadRules​(String ruleFile)` | Deprecated.

  - ### 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)` | Returns the head constituent for the specified constituents of the specified type.
    `Set<String>` | `getPunctuationTags()` | Returns the set of punctuation tags.
    `int` | `hashCode()` |
    `void` | `labelGaps​(Stack<Constituent> stack)` | Labels the constituents found in the stack with gap labels if appropriate.
    `void` | `serialize​(Writer writer)` | Writes the head rules to the writer in a format suitable for loading the head rules again with the constructor.

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

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

- - ### Constructor Detail

    - #### HeadRules

          @Deprecated
          public HeadRules​(String ruleFile)
                    throws IOException

      Deprecated.
      Creates a new set of head rules based on the specified head rules file.
      Parameters:
        `ruleFile` - the head rules file.
      Throws:
        `IOException` - 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` - the head rules reader.
      Throws:
        `IOException` - if the head rules reader can not be read.

  - ### Method Detail

    - #### getPunctuationTags

          public Set<String> getPunctuationTags()

      Description copied from interface: `HeadRules`
      Returns the set of punctuation tags. Attachment decisions for these tags will not be modeled.
      Specified by:
        `getPunctuationTags` in interface `HeadRules`
      Returns:
        the set of punctuation tags.

    - #### getHead

          public Parse getHead​(Parse[] constituents,
                               String type)

      Description copied from interface: `HeadRules`
      Returns the head constituent for the specified constituents of the specified type.
      Specified by:
        `getHead` in interface `HeadRules`
      Parameters:
        `constituents` - The constituents which make up a constituent of the specified type.
        `type` - The type of a constituent which is made up of the specified constituents.
      Returns:
        The constituent which is the head.

    - #### labelGaps

          public void labelGaps​(Stack<Constituent> stack)

      Description copied from interface: `GapLabeler`
      Labels the constituents found in the stack with gap labels if appropriate.
      Specified by:
        `labelGaps` in interface `GapLabeler`
      Parameters:
        `stack` - The stack of un-completed constituents.

    - #### serialize

          public void serialize​(Writer writer)
                         throws IOException

      Writes the head rules to the writer in a format suitable for loading the head rules again with the constructor. The encoding must be taken into account while working with the writer and reader.

      After the entries have been written, the writer is flushed. The writer remains open after this method returns.

      Parameters:
        `writer` -
      Throws:
        `IOException`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### equals

          public boolean equals​(Object obj)

      Overrides:
        `equals` in class `Object`

    - #### 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 interface `SerializableArtifact`
      Returns:
        the corresponding ArtifactSerializer class.