Package morfologik.fsa.builders
Class ConstantArcSizeFSA
- java.lang.Object
-
- morfologik.fsa.FSA
-
- morfologik.fsa.builders.ConstantArcSizeFSA
-
- All Implemented Interfaces:
java.lang.Iterable<java.nio.ByteBuffer>
final class ConstantArcSizeFSA extends FSA
An FSA with constant-size arc representation produced directly byFSABuilder.- See Also:
FSABuilder
-
-
Field Summary
Fields Modifier and Type Field Description static intADDRESS_OFFSETOffset of the address field inside an arc.static intARC_SIZESize of a single arc structure.static intBIT_ARC_FINALAn arc flag indicating the target node of an arc corresponds to a final state.static intBIT_ARC_LASTAn arc flag indicating the arc is last within its state.private byte[]dataFSA data, serialized as a byte array.private intepsilonAn epsilon state.static intFLAGS_OFFSETOffset of the flags field inside an arc.static intFLAGS_SIZESize of the flags field (constant for the builder).static intLABEL_OFFSETOffset of the label field inside an arc.static intLABEL_SIZESize of the label field (constant for the builder).static intTARGET_ADDRESS_SIZESize of the target address field (constant for the builder).(package private) static intTERMINAL_STATEA dummy address of the terminal state.
-
Constructor Summary
Constructors Constructor Description ConstantArcSizeFSA(byte[] data, int epsilon)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetArc(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)java.util.Set<FSAFlags>getFlags()intgetNextArc(int arc)intgetRootNode()booleanisArcFinal(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, visitInPreOrder
-
-
-
-
Field Detail
-
TARGET_ADDRESS_SIZE
public static final int TARGET_ADDRESS_SIZE
Size of the target address field (constant for the builder).- See Also:
- Constant Field Values
-
FLAGS_SIZE
public static final int FLAGS_SIZE
Size of the flags field (constant for the builder).- See Also:
- Constant Field Values
-
LABEL_SIZE
public static final int LABEL_SIZE
Size of the label field (constant for the builder).- See Also:
- Constant Field Values
-
ARC_SIZE
public static final int ARC_SIZE
Size of a single arc structure.- See Also:
- Constant Field Values
-
FLAGS_OFFSET
public static final int FLAGS_OFFSET
Offset of the flags field inside an arc.- See Also:
- Constant Field Values
-
LABEL_OFFSET
public static final int LABEL_OFFSET
Offset of the label field inside an arc.- See Also:
- Constant Field Values
-
ADDRESS_OFFSET
public static final int ADDRESS_OFFSET
Offset of the address field inside an arc.- See Also:
- Constant Field Values
-
TERMINAL_STATE
static final int TERMINAL_STATE
A dummy address of the terminal state.- See Also:
- Constant Field Values
-
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:
- Constant Field Values
-
BIT_ARC_LAST
public static final int BIT_ARC_LAST
An arc flag indicating the arc is last within its state.- See Also:
- Constant Field Values
-
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.
-
-
Method Detail
-
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.
-
-