Record Class Morpheme

java.lang.Object
java.lang.Record
opennlp.tools.tokenize.lattice.Morpheme
Record Components:
span - The location of the morpheme in the original text. Must not be null.
surface - The covered text. Must not be null or empty.
features - The dictionary feature columns. Must not be null.
unknown - Whether the morpheme came from unknown-word handling rather than a lexicon entry.

public record Morpheme(Span span, String surface, List<String> features, boolean unknown) extends Record
One morpheme from lattice segmentation: the Span it covers in the original text, its surface form, and the feature columns its dictionary entry carries.

The features are the entry's columns exactly as listed in the dictionary, since different dictionaries carry different schemas: part of speech first by convention, then dictionary-specific columns such as conjugation, base form, or reading. A morpheme produced by unknown-word handling has the unknown entry's features and is marked as such.

Since:
3.0.0
  • Constructor Details

    • Morpheme

      public Morpheme(Span span, String surface, List<String> features, boolean unknown)
      Validates the morpheme.
      Throws:
      IllegalArgumentException - Thrown if span, surface, or features is null, or surface is empty.
  • Method Details

    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • span

      public Span span()
      Returns the value of the span record component.
      Returns:
      the value of the span record component
    • surface

      public String surface()
      Returns the value of the surface record component.
      Returns:
      the value of the surface record component
    • features

      public List<String> features()
      Returns the value of the features record component.
      Returns:
      the value of the features record component
    • unknown

      public boolean unknown()
      Returns the value of the unknown record component.
      Returns:
      the value of the unknown record component