public final class FST<T> extends Object
The format is similar to what's used by Morfologik (http://sourceforge.net/projects/morfologik).
NOTE: the FST cannot be larger than ~2.1 GB because it uses int to address the byte[].
Modifier and Type | Class and Description |
---|---|
static class |
FST.Arc<T>
Represents a single arc.
|
static class |
FST.BytesReader
Reads the bytes from this FST.
|
static class |
FST.INPUT_TYPE
Specifies allowed range of each int input label for
this FST.
|
Modifier and Type | Field and Description |
---|---|
int |
arcCount |
int |
arcWithOutputCount |
static int |
END_LABEL |
FST.INPUT_TYPE |
inputType |
int |
nodeCount |
Outputs<T> |
outputs |
Constructor and Description |
---|
FST(DataInput in,
Outputs<T> outputs)
Load a previously saved FST.
|
Modifier and Type | Method and Description |
---|---|
FST.Arc<T> |
findTargetArc(int labelToMatch,
FST.Arc<T> follow,
FST.Arc<T> arc,
FST.BytesReader in)
Finds an arc leaving the incoming arc, replacing the arc in place.
|
int |
getArcCount() |
int |
getArcWithOutputCount() |
FST.BytesReader |
getBytesReader(int pos) |
T |
getEmptyOutput() |
FST.Arc<T> |
getFirstArc(FST.Arc<T> arc)
Fills virtual 'start' arc, ie, an empty incoming arc to
the FST's start node
|
FST.INPUT_TYPE |
getInputType() |
int |
getNodeCount() |
FST<T> |
pack(int minInCountDeref,
int maxDerefNodes)
Expert: creates an FST by packing this one.
|
static <T> FST<T> |
read(File file,
Outputs<T> outputs)
Reads an automaton from a file.
|
FST.Arc<T> |
readFirstRealTargetArc(int node,
FST.Arc<T> arc,
FST.BytesReader in) |
FST.Arc<T> |
readFirstTargetArc(FST.Arc<T> follow,
FST.Arc<T> arc)
Follow the
follow arc and read the first arc of its target;
this changes the provided arc (2nd arg) in-place and returns
it. |
FST.Arc<T> |
readLastTargetArc(FST.Arc<T> follow,
FST.Arc<T> arc)
Follows the
follow arc and reads the last
arc of its target; this changes the provided
arc (2nd arg) in-place and returns it. |
FST.Arc<T> |
readNextArc(FST.Arc<T> arc)
In-place read; returns the arc.
|
int |
readNextArcLabel(FST.Arc<T> arc)
Peeks at next arc's label; does not alter arc.
|
FST.Arc<T> |
readNextRealArc(FST.Arc<T> arc,
FST.BytesReader in)
Never returns null, but you should never call this if
arc.isLast() is true.
|
void |
save(DataOutput out) |
void |
save(File file)
Writes an automaton to a file.
|
void |
setAllowArrayArcs(boolean v) |
int |
sizeInBytes()
Returns bytes used to represent the FST
|
static <T> boolean |
targetHasArcs(FST.Arc<T> arc) |
public final FST.INPUT_TYPE inputType
public int nodeCount
public int arcCount
public int arcWithOutputCount
public static final int END_LABEL
public FST(DataInput in, Outputs<T> outputs) throws IOException
IOException
public FST.INPUT_TYPE getInputType()
public int sizeInBytes()
public T getEmptyOutput()
public void save(DataOutput out) throws IOException
IOException
public void save(File file) throws IOException
IOException
public static <T> FST<T> read(File file, Outputs<T> outputs) throws IOException
IOException
public static <T> boolean targetHasArcs(FST.Arc<T> arc)
public FST.Arc<T> getFirstArc(FST.Arc<T> arc)
public FST.Arc<T> readLastTargetArc(FST.Arc<T> follow, FST.Arc<T> arc) throws IOException
follow
arc and reads the last
arc of its target; this changes the provided
arc
(2nd arg) in-place and returns it.arc
).IOException
public FST.Arc<T> readFirstTargetArc(FST.Arc<T> follow, FST.Arc<T> arc) throws IOException
follow
arc and read the first arc of its target;
this changes the provided arc
(2nd arg) in-place and returns
it.arc
).IOException
public FST.Arc<T> readFirstRealTargetArc(int node, FST.Arc<T> arc, FST.BytesReader in) throws IOException
IOException
public FST.Arc<T> readNextArc(FST.Arc<T> arc) throws IOException
IOException
public int readNextArcLabel(FST.Arc<T> arc) throws IOException
IOException
public FST.Arc<T> readNextRealArc(FST.Arc<T> arc, FST.BytesReader in) throws IOException
IOException
public FST.Arc<T> findTargetArc(int labelToMatch, FST.Arc<T> follow, FST.Arc<T> arc, FST.BytesReader in) throws IOException
IOException
public int getNodeCount()
public int getArcCount()
public int getArcWithOutputCount()
public void setAllowArrayArcs(boolean v)
public final FST.BytesReader getBytesReader(int pos)
public FST<T> pack(int minInCountDeref, int maxDerefNodes) throws IOException
IOException