Package opennlp.tools.depparse
Record Class Transition
java.lang.Object
java.lang.Record
opennlp.tools.depparse.Transition
- Record Components:
type- The kind of action. Must not benull.label- The relation label for arc actions,nullforTransition.Type.SHIFT.
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 ClassesModifier and TypeClassDescription(package private) static enumThe kinds of arc-standard action. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final StringThe field for thelabelrecord component.private static final charSeparates the type name from the label in an encoded arc transition.(package private) static final TransitionThe single shift transition; shifts carry no label.private final Transition.TypeThe field for thetyperecord component. -
Constructor Summary
ConstructorsConstructorDescriptionTransition(Transition.Type type, String label) Validates the pairing of type and label. -
Method Summary
Modifier and TypeMethodDescription(package private) static TransitionRestores a transition from a model outcome string produced byencode().(package private) static Transition[]decodeInventory(String[] outcomes) Decodes a transition inventory: the outcomes of a parser model, in index order.(package private) Stringencode()Renders the transition as a model outcome string, for exampleSHIFTorLEFT_ARC:nsubj.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.label()Returns the value of thelabelrecord component.(package private) static TransitionCreates a left-arc transition.(package private) static TransitionCreates a right-arc transition.final StringtoString()Returns a string representation of this record class.type()Returns the value of thetyperecord component.
-
Field Details
-
Constructor Details
-
Transition
Transition(Transition.Type type, String label) Validates the pairing of type and label.- Throws:
IllegalArgumentException- Thrown iftypeisnull, a shift carries a label, or an arc action has anullor blank label.
-
-
Method Details
-
leftArc
Creates a left-arc transition.- Parameters:
label- The relation label. Must not benullor blank.- Returns:
- A
TransitionofTransition.Type.LEFT_ARC. Nevernull. - Throws:
IllegalArgumentException- Thrown iflabelisnullor blank.
-
rightArc
Creates a right-arc transition.- Parameters:
label- The relation label. Must not benullor blank.- Returns:
- A
TransitionofTransition.Type.RIGHT_ARC. Nevernull. - Throws:
IllegalArgumentException- Thrown iflabelisnullor blank.
-
encode
String encode()Renders the transition as a model outcome string, for exampleSHIFTorLEFT_ARC:nsubj.- Returns:
- The outcome string. Never
null.
-
decode
Restores a transition from a model outcome string produced byencode().- Parameters:
outcome- The outcome string. Must not benull.- Returns:
- The decoded
Transition. Nevernull. - Throws:
IllegalArgumentException- Thrown ifoutcomeisnullor does not name a valid transition.
-
decodeInventory
Decodes a transition inventory: the outcomes of a parser model, in index order.- Parameters:
outcomes- The outcome strings. Must not benull.- Returns:
- The decoded transitions, indexed like
outcomes. Nevernull. - 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
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. -
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. -
equals
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 withObjects::equals(Object,Object). -
type
Returns the value of thetyperecord component.- Returns:
- the value of the
typerecord component
-
label
Returns the value of thelabelrecord component.- Returns:
- the value of the
labelrecord component
-