Package morfologik.fsa.builders
Class ConstantArcSizeFSA
java.lang.Object
morfologik.fsa.FSA
morfologik.fsa.builders.ConstantArcSizeFSA
- All Implemented Interfaces:
Iterable<ByteBuffer>
An FSA with constant-size arc representation produced directly by
FSABuilder.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intOffset of the address field inside an arc.static final intSize of a single arc structure.static final intAn arc flag indicating the target node of an arc corresponds to a final state.static final intAn arc flag indicating the arc is last within its state.private final byte[]FSA data, serialized as a byte array.private final intAn epsilon state.static final intOffset of the flags field inside an arc.static final intSize of the flags field (constant for the builder).static final intOffset of the label field inside an arc.static final intSize of the label field (constant for the builder).static final intSize of the target address field (constant for the builder).(package private) static final intA dummy address of the terminal state. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintgetArc(int node, byte label) bytegetArcLabel(int arc) private intgetArcTarget(int arc) Fills the target state address of an arc.intgetEndNode(int arc) intgetFirstArc(int node) getFlags()intgetNextArc(int arc) intbooleanisArcFinal(int arc) private booleanisArcLast(int arc) booleanisArcTerminal(int arc) Methods inherited from class morfologik.fsa.FSA
getArcCount, getRightLanguageCount, getSequences, getSequences, iterator, read, read, readRemaining, visitAllStates, visitInPostOrder, visitInPostOrder, visitInPreOrder, visitInPreOrderMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
TARGET_ADDRESS_SIZE
public static final int TARGET_ADDRESS_SIZESize of the target address field (constant for the builder).- See Also:
-
FLAGS_SIZE
public static final int FLAGS_SIZESize of the flags field (constant for the builder).- See Also:
-
LABEL_SIZE
public static final int LABEL_SIZESize of the label field (constant for the builder).- See Also:
-
ARC_SIZE
public static final int ARC_SIZESize of a single arc structure.- See Also:
-
FLAGS_OFFSET
public static final int FLAGS_OFFSETOffset of the flags field inside an arc.- See Also:
-
LABEL_OFFSET
public static final int LABEL_OFFSETOffset of the label field inside an arc.- See Also:
-
ADDRESS_OFFSET
public static final int ADDRESS_OFFSETOffset of the address field inside an arc.- See Also:
-
TERMINAL_STATE
static final int TERMINAL_STATEA dummy address of the terminal state.- See Also:
-
BIT_ARC_FINAL
public static final int BIT_ARC_FINALAn 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_LASTAn arc flag indicating the arc is last within its state.- See Also:
-
epsilon
private final int epsilonAn 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[] dataFSA 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:
getRootNodein classFSA- 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:
getFirstArcin classFSA- Parameters:
node- Identifier of the node.- Returns:
- Returns the identifier of the first arc leaving
nodeor 0 if the node has no outgoing arcs.
-
getArc
public int getArc(int node, byte label) -
getNextArc
public int getNextArc(int arc) - Specified by:
getNextArcin classFSA- Parameters:
arc- The arc's identifier.- Returns:
- Returns the identifier of the next arc after
arcand leavingnode. Zero is returned if no more arcs are available for the node.
-
getArcLabel
public byte getArcLabel(int arc) - Specified by:
getArcLabelin classFSA- 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:
isArcFinalin classFSA- Parameters:
arc- The arc's identifier.- Returns:
- Returns
trueif the destination node at the end of thisarccorresponds to an input sequence created when building this automaton.
-
isArcTerminal
public boolean isArcTerminal(int arc) - Specified by:
isArcTerminalin classFSA- Parameters:
arc- The arc's identifier.- Returns:
- Returns
trueif thisarcdoes not have a terminating node (@linkFSA.getEndNode(int)will throw an exception). ImpliesFSA.isArcFinal(int).
-
isArcLast
private boolean isArcLast(int arc) -
getEndNode
public int getEndNode(int arc) - Specified by:
getEndNodein classFSA- 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
-