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 int
ADDRESS_OFFSET
Offset of the address field inside an arc.static int
ARC_SIZE
Size of a single arc structure.static int
BIT_ARC_FINAL
An arc flag indicating the target node of an arc corresponds to a final state.static int
BIT_ARC_LAST
An arc flag indicating the arc is last within its state.private byte[]
data
FSA data, serialized as a byte array.private int
epsilon
An epsilon state.static int
FLAGS_OFFSET
Offset of the flags field inside an arc.static int
FLAGS_SIZE
Size of the flags field (constant for the builder).static int
LABEL_OFFSET
Offset of the label field inside an arc.static int
LABEL_SIZE
Size of the label field (constant for the builder).static int
TARGET_ADDRESS_SIZE
Size of the target address field (constant for the builder).(package private) static int
TERMINAL_STATE
A 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 int
getArc(int node, byte label)
byte
getArcLabel(int arc)
private int
getArcTarget(int arc)
Fills the target state address of an arc.int
getEndNode(int arc)
int
getFirstArc(int node)
java.util.Set<FSAFlags>
getFlags()
int
getNextArc(int arc)
int
getRootNode()
boolean
isArcFinal(int arc)
private boolean
isArcLast(int arc)
boolean
isArcTerminal(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:
getRootNode
in 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:
getFirstArc
in classFSA
- 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)
-
getNextArc
public int getNextArc(int arc)
- Specified by:
getNextArc
in classFSA
- Parameters:
arc
- The arc's identifier.- Returns:
- Returns the identifier of the next arc after
arc
and leavingnode
. Zero is returned if no more arcs are available for the node.
-
getArcLabel
public byte getArcLabel(int arc)
- Specified by:
getArcLabel
in 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:
isArcFinal
in classFSA
- Parameters:
arc
- The arc's identifier.- Returns:
- Returns
true
if the destination node at the end of thisarc
corresponds to an input sequence created when building this automaton.
-
isArcTerminal
public boolean isArcTerminal(int arc)
- Specified by:
isArcTerminal
in classFSA
- Parameters:
arc
- The arc's identifier.- Returns:
- Returns
true
if thisarc
does 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:
getEndNode
in 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.
-
-