Class ConstantArcSizeFSA

java.lang.Object
morfologik.fsa.FSA
morfologik.fsa.builders.ConstantArcSizeFSA
All Implemented Interfaces:
Iterable<ByteBuffer>

final class ConstantArcSizeFSA extends FSA
An FSA with constant-size arc representation produced directly by FSABuilder.
See Also:
  • Field Details

    • TARGET_ADDRESS_SIZE

      public static final int TARGET_ADDRESS_SIZE
      Size of the target address field (constant for the builder).
      See Also:
    • FLAGS_SIZE

      public static final int FLAGS_SIZE
      Size of the flags field (constant for the builder).
      See Also:
    • LABEL_SIZE

      public static final int LABEL_SIZE
      Size of the label field (constant for the builder).
      See Also:
    • ARC_SIZE

      public static final int ARC_SIZE
      Size of a single arc structure.
      See Also:
    • FLAGS_OFFSET

      public static final int FLAGS_OFFSET
      Offset of the flags field inside an arc.
      See Also:
    • LABEL_OFFSET

      public static final int LABEL_OFFSET
      Offset of the label field inside an arc.
      See Also:
    • ADDRESS_OFFSET

      public static final int ADDRESS_OFFSET
      Offset of the address field inside an arc.
      See Also:
    • TERMINAL_STATE

      static final int TERMINAL_STATE
      A dummy address of the terminal state.
      See Also:
    • BIT_ARC_FINAL

      public static final int BIT_ARC_FINAL
      An arc flag indicating the target node of an arc corresponds to a final state.
      See Also:
    • BIT_ARC_LAST

      public static final int BIT_ARC_LAST
      An arc flag indicating the arc is last within its state.
      See Also:
    • epsilon

      private final int epsilon
      An epsilon state. The first and only arc of this state points either to the root or to the terminal state, indicating an empty automaton.
    • data

      private final byte[] data
      FSA data, serialized as a byte array.
  • Constructor Details

    • ConstantArcSizeFSA

      ConstantArcSizeFSA(byte[] data, int epsilon)
      Parameters:
      data - FSA data. There must be no trailing bytes after the last state.
  • Method Details

    • getRootNode

      public int getRootNode()
      Specified by:
      getRootNode in class FSA
      Returns:
      Returns the identifier of the root node of this automaton. Returns 0 if the start node is also the end node (the automaton is empty).
    • getFirstArc

      public int getFirstArc(int node)
      Specified by:
      getFirstArc in class FSA
      Parameters:
      node - Identifier of the node.
      Returns:
      Returns the identifier of the first arc leaving node or 0 if the node has no outgoing arcs.
    • getArc

      public int getArc(int node, byte label)
      Specified by:
      getArc in class FSA
      Parameters:
      node - Identifier of the node.
      label - The arc's label.
      Returns:
      Returns the identifier of an arc leaving node and labeled with label. An identifier equal to 0 means the node has no outgoing arc labeled label.
    • getNextArc

      public int getNextArc(int arc)
      Specified by:
      getNextArc in class FSA
      Parameters:
      arc - The arc's identifier.
      Returns:
      Returns the identifier of the next arc after arc and leaving node. Zero is returned if no more arcs are available for the node.
    • getArcLabel

      public byte getArcLabel(int arc)
      Specified by:
      getArcLabel in class FSA
      Parameters:
      arc - The arc's identifier.
      Returns:
      Return the label associated with a given arc.
    • getArcTarget

      private int getArcTarget(int arc)
      Fills the target state address of an arc.
    • isArcFinal

      public boolean isArcFinal(int arc)
      Specified by:
      isArcFinal in class FSA
      Parameters:
      arc - The arc's identifier.
      Returns:
      Returns true if the destination node at the end of this arc corresponds to an input sequence created when building this automaton.
    • isArcTerminal

      public boolean isArcTerminal(int arc)
      Specified by:
      isArcTerminal in class FSA
      Parameters:
      arc - The arc's identifier.
      Returns:
      Returns true if this arc does not have a terminating node (@link FSA.getEndNode(int) will throw an exception). Implies FSA.isArcFinal(int).
    • isArcLast

      private boolean isArcLast(int arc)
    • getEndNode

      public int getEndNode(int arc)
      Specified by:
      getEndNode in class FSA
      Parameters:
      arc - The arc's identifier.
      Returns:
      Return the end node pointed to by a given arc. Terminal arcs (those that point to a terminal state) have no end node representation and throw a runtime exception.
    • getFlags

      public Set<FSAFlags> getFlags()
      Specified by:
      getFlags in class FSA
      Returns:
      Returns a set of flags for this FSA instance.