|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcc.mallet.fst.semi_supervised.StateLabelMap
public class StateLabelMap
Maps states in the lattice to labels.
When a custom state machine is constructed while training a CRF, it is possible that several states map to the same label. In this case, there will be a discrepancy between the number of states used in the lattice and the number of output labels (targets). Use this mapping if such an FST is used in training a CRF model.
If the number of states in the lattice is expected to be equal to the number of output labels, then set isOneToOneMap to true in the constructor.
This map associates the state with the appropriate label (indexing is zero onwards).
Note: Add the states to the map in the same order in which they are added to the CRF while constructing the FST. This is necessary to keep a correct mapping of the state indices in this map to the state indices used within the CRF.
| Constructor Summary | |
|---|---|
StateLabelMap(Alphabet labelAlphabet,
boolean isOneToOneMap)
Initializes the state and label maps. |
|
| Method Summary | |
|---|---|
int |
addState(java.lang.String stateName,
java.lang.String labelName)
Adds a state to the map. |
Alphabet |
getLabelAlphabet()
Returns the label (target) alphabet. |
int |
getLabelIndex(int stateIndex)
Returns the label index mapped to the state index. |
int |
getNumLabels()
Returns the number of labels in the map. |
int |
getNumStates()
Returns the number of states in the map. |
Alphabet |
getStateAlphabet()
Returns the state alphabet. |
java.util.LinkedHashSet<java.lang.Integer> |
getStateIndices(int labelIndex)
Returns the state indices that map to the label index. |
boolean |
isOneToOneMapping()
Returns true if there is a one-to-one mapping between the states and labels and false otherwise. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public StateLabelMap(Alphabet labelAlphabet,
boolean isOneToOneMap)
labelAlphabet - Target alphabet that maps label names to integers.isOneToOneMap - True if a one to one mapping of states and labels
is to be created.| Method Detail |
|---|
public boolean isOneToOneMapping()
public int getNumLabels()
public int getNumStates()
public Alphabet getLabelAlphabet()
public Alphabet getStateAlphabet()
public int getLabelIndex(int stateIndex)
stateIndex - State index.
public java.util.LinkedHashSet<java.lang.Integer> getStateIndices(int labelIndex)
labelIndex - Label (target) index.
public int addState(java.lang.String stateName,
java.lang.String labelName)
stateName - Name of the state.labelName - Label (target) name with which the state is associated.
java.lang.IllegalArgumentException - If an invalid label name or a duplicate
state name is provided.
IllegalStateError - If this method is called when there is a
one-to-one mapping between the states and labels.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||