Record Class Transition

java.lang.Object
java.lang.Record
opennlp.tools.depparse.Transition
Record Components:
type - The kind of action. Must not be null.
label - The relation label for arc actions, null for Transition.Type.SHIFT.

record Transition(Transition.Type type, String label) extends Record
One action of the arc-standard transition system: shift the next buffer token onto the stack, or attach one of the two topmost stack tokens to the other under a relation label.

encode() renders a transition as a classification outcome and decode(String) restores it.

Since:
3.0.0
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    (package private) static enum 
    The kinds of arc-standard action.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final String
    The field for the label record component.
    private static final char
    Separates the type name from the label in an encoded arc transition.
    (package private) static final Transition
    The single shift transition; shifts carry no label.
    private final Transition.Type
    The field for the type record component.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Validates the pairing of type and label.
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) static Transition
    decode(String outcome)
    Restores a transition from a model outcome string produced by encode().
    (package private) static Transition[]
    decodeInventory(String[] outcomes)
    Decodes a transition inventory: the outcomes of a parser model, in index order.
    (package private) String
    Renders the transition as a model outcome string, for example SHIFT or LEFT_ARC:nsubj.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    Returns the value of the label record component.
    (package private) static Transition
    leftArc(String label)
    Creates a left-arc transition.
    (package private) static Transition
    Creates a right-arc transition.
    final String
    Returns a string representation of this record class.
    Returns the value of the type record component.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • type

      private final Transition.Type type
      The field for the type record component.
    • label

      private final String label
      The field for the label record component.
    • SHIFT

      static final Transition SHIFT
      The single shift transition; shifts carry no label.
    • SEPARATOR

      private static final char SEPARATOR
      Separates the type name from the label in an encoded arc transition.
      See Also:
  • Constructor Details

    • Transition

      Transition(Transition.Type type, String label)
      Validates the pairing of type and label.
      Throws:
      IllegalArgumentException - Thrown if type is null, a shift carries a label, or an arc action has a null or blank label.
  • Method Details

    • leftArc

      static Transition leftArc(String label)
      Creates a left-arc transition.
      Parameters:
      label - The relation label. Must not be null or blank.
      Returns:
      A Transition of Transition.Type.LEFT_ARC. Never null.
      Throws:
      IllegalArgumentException - Thrown if label is null or blank.
    • rightArc

      static Transition rightArc(String label)
      Creates a right-arc transition.
      Parameters:
      label - The relation label. Must not be null or blank.
      Returns:
      A Transition of Transition.Type.RIGHT_ARC. Never null.
      Throws:
      IllegalArgumentException - Thrown if label is null or blank.
    • encode

      String encode()
      Renders the transition as a model outcome string, for example SHIFT or LEFT_ARC:nsubj.
      Returns:
      The outcome string. Never null.
    • decode

      static Transition decode(String outcome)
      Restores a transition from a model outcome string produced by encode().
      Parameters:
      outcome - The outcome string. Must not be null.
      Returns:
      The decoded Transition. Never null.
      Throws:
      IllegalArgumentException - Thrown if outcome is null or does not name a valid transition.
    • decodeInventory

      static Transition[] decodeInventory(String[] outcomes)
      Decodes a transition inventory: the outcomes of a parser model, in index order.
      Parameters:
      outcomes - The outcome strings. Must not be null.
      Returns:
      The decoded transitions, indexed like outcomes. Never null.
      Throws:
      IllegalArgumentException - Thrown if an outcome is not a transition, a transition repeats, or the inventory has no SHIFT or no RIGHT_ARC action.
    • 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. All components in this record class are compared with Objects::equals(Object,Object).
      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.
    • type

      public Transition.Type type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • label

      public String label()
      Returns the value of the label record component.
      Returns:
      the value of the label record component