public class Fst
extends java.lang.Object
State
objects allowing
additions/deletions.Modifier and Type | Field and Description |
---|---|
protected java.lang.String[] |
isyms |
protected java.lang.String[] |
osyms |
protected Semiring |
semiring |
protected State |
start |
Constructor and Description |
---|
Fst()
Default Constructor
|
Fst(int numStates)
Constructor specifying the initial capacity of the states ArrayList (this
is an optimization used in various operations)
|
Fst(Semiring s)
Constructor specifying the fst's semiring
|
Modifier and Type | Method and Description |
---|---|
void |
addState(State state)
Adds a state to the fst
|
void |
deleteState(State state)
Deletes a state
|
void |
deleteStates(java.util.HashSet<State> toDelete) |
boolean |
equals(java.lang.Object obj) |
java.lang.String[] |
getIsyms()
Get the input symbols' array
|
int |
getNumStates()
Get the number of states in the fst
|
java.lang.String[] |
getOsyms()
Get the output symbols' array
|
Semiring |
getSemiring()
Get the semiring
|
State |
getStart()
Get the initial states
|
State |
getState(int index) |
int |
hashCode() |
static Fst |
loadModel(java.lang.String filename)
Deserializes an Fst from disk
|
protected static java.lang.String[] |
readStringMap(java.io.ObjectInputStream in)
Deserializes a symbol map from an ObjectInputStream
|
void |
remapStateIds()
Remaps the states' ids.
|
void |
saveModel(java.lang.String filename)
Saves binary model to disk
|
void |
setIsyms(java.lang.String[] isyms)
Set the input symbols
|
void |
setOsyms(java.lang.String[] osyms)
Set the output symbols
|
void |
setSemiring(Semiring semiring)
Set the Semiring
|
void |
setStart(State start)
Set the initial state
|
java.lang.String |
toString() |
protected State start
protected java.lang.String[] isyms
protected java.lang.String[] osyms
protected Semiring semiring
public Fst()
public Fst(int numStates)
numStates
- the initial capacitypublic Fst(Semiring s)
s
- the fst's semiringpublic State getStart()
public Semiring getSemiring()
public void setSemiring(Semiring semiring)
semiring
- the semiring to setpublic void setStart(State start)
start
- the initial statepublic int getNumStates()
public State getState(int index)
public void addState(State state)
state
- the state to be addedpublic java.lang.String[] getIsyms()
public void setIsyms(java.lang.String[] isyms)
isyms
- the isyms to setpublic java.lang.String[] getOsyms()
public void setOsyms(java.lang.String[] osyms)
osyms
- the osyms to setpublic void saveModel(java.lang.String filename) throws java.io.IOException
filename
- the binary model filenamejava.io.IOException
- if IO went wrongprotected static java.lang.String[] readStringMap(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException
in
- the ObjectInputStream. It should be already be initialized by
the caller.java.io.IOException
- if IO went wrongjava.lang.ClassNotFoundException
- if serialization went wrongpublic static Fst loadModel(java.lang.String filename) throws java.io.IOException, java.lang.ClassNotFoundException
filename
- the binary model filenamejava.io.IOException
- io IO went wrongjava.lang.ClassNotFoundException
- if serialization went wrongpublic boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public void deleteState(State state)
state
- the state to deletepublic void remapStateIds()
getNumStates()
public void deleteStates(java.util.HashSet<State> toDelete)