本文整理汇总了Java中cc.mallet.fst.Transducer.numStates方法的典型用法代码示例。如果您正苦于以下问题:Java Transducer.numStates方法的具体用法?Java Transducer.numStates怎么用?Java Transducer.numStates使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cc.mallet.fst.Transducer
的用法示例。
在下文中一共展示了Transducer.numStates方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: GELattice
import cc.mallet.fst.Transducer; //导入方法依赖的package包/类
/**
* @param fvs Input FeatureVectorSequence
* @param gammas Marginals over single states
* @param xis Marginals over pairs of states
* @param transducer Transducer
* @param reverseTrans Source state indices for each destination state
* @param reverseTransIndices Transition indices for each destination state
* @param gradient Gradient to increment
* @param constraints List of constraints
* @param check Whether to run the debugging test to verify correctness (will be much slower if true)
*/
public GELattice(
FeatureVectorSequence fvs, double[][] gammas, double[][][] xis,
Transducer transducer, int[][] reverseTrans, int[][] reverseTransIndices, CRF.Factors gradient,
ArrayList<GEConstraint> constraints, boolean check) {
assert(gradient != null);
latticeLength = fvs.size() + 1;
this.transducer = transducer;
numStates = transducer.numStates();
// lattice
lattice = new LatticeNode[latticeLength][numStates];
for (int ip = 0; ip < latticeLength; ++ip) {
for (int a = 0; a < numStates; ++a) {
lattice[ip][a] = new LatticeNode();
}
}
dotCache = new LogNumber[latticeLength][numStates][numStates];
// TODO maybe this should be cached?
// Separate lists for constraints that look at one vs two states.
ArrayList<GEConstraint> constraints1 = new ArrayList<GEConstraint>();
ArrayList<GEConstraint> constraints2 = new ArrayList<GEConstraint>();
for (GEConstraint constraint : constraints) {
if (constraint.isOneStateConstraint()) {
constraints1.add(constraint);
}
else {
constraints2.add(constraint);
}
}
CRF crf = (CRF)transducer;
double dotEx = this.runForward(crf, constraints1, constraints2, gammas, xis, reverseTrans, fvs);
this.runBackward(crf, gammas, xis, reverseTrans, reverseTransIndices, fvs, dotEx, gradient);
//check(constraints,gammas,xis,fvs);
}