本文整理汇总了Java中cc.mallet.types.FeatureVectorSequence.getFeatureVector方法的典型用法代码示例。如果您正苦于以下问题:Java FeatureVectorSequence.getFeatureVector方法的具体用法?Java FeatureVectorSequence.getFeatureVector怎么用?Java FeatureVectorSequence.getFeatureVector使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cc.mallet.types.FeatureVectorSequence
的用法示例。
在下文中一共展示了FeatureVectorSequence.getFeatureVector方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: computeExpectations
import cc.mallet.types.FeatureVectorSequence; //导入方法依赖的package包/类
public void computeExpectations(ArrayList<SumLattice> lattices) {
double[][][] xis;
TIntArrayList cache = new TIntArrayList();
for (int i = 0; i < lattices.size(); i++) {
if (lattices.get(i) == null) { continue; }
FeatureVectorSequence fvs = (FeatureVectorSequence)lattices.get(i).getInput();
SumLattice lattice = lattices.get(i);
xis = lattice.getXis();
for (int ip = 1; ip < fvs.size(); ++ip) {
cache.resetQuick();
FeatureVector fv = fvs.getFeatureVector(ip);
int fi;
for (int loc = 0; loc < fv.numLocations(); loc++) {
fi = fv.indexAtLocation(loc);
// binary constraint features
if (constraintsMap.containsKey(fi)) {
cache.add(constraintsMap.get(fi));
}
}
for (int prev = 0; prev < map.getNumStates(); ++prev) {
int liPrev = map.getLabelIndex(prev);
if (liPrev != StateLabelMap.START_LABEL) {
for (int curr = 0; curr < map.getNumStates(); ++curr) {
int liCurr = map.getLabelIndex(curr);
if (liCurr != StateLabelMap.START_LABEL) {
double prob = Math.exp(xis[ip][prev][curr]);
for (int j = 0; j < cache.size(); j++) {
constraintsList.get(cache.getQuick(j)).expectation[liPrev][liCurr] += prob;
}
}
}
}
}
}
}
}
示例2: computeExpectations
import cc.mallet.types.FeatureVectorSequence; //导入方法依赖的package包/类
public void computeExpectations(ArrayList<SumLattice> lattices) {
double[][] gammas;
TIntArrayList cache = new TIntArrayList();
for (int i = 0; i < lattices.size(); i++) {
if (lattices.get(i) == null) { continue; }
SumLattice lattice = lattices.get(i);
FeatureVectorSequence fvs = (FeatureVectorSequence)lattice.getInput();
gammas = lattice.getGammas();
for (int ip = 0; ip < fvs.size(); ++ip) {
cache.resetQuick();
FeatureVector fv = fvs.getFeatureVector(ip);
int fi;
for (int loc = 0; loc < fv.numLocations(); loc++) {
fi = fv.indexAtLocation(loc);
// binary constraint features
if (constraints.containsKey(fi)) {
cache.add(fi);
}
}
if (constraints.containsKey(fv.getAlphabet().size())) {
cache.add(fv.getAlphabet().size());
}
for (int s = 0; s < map.getNumStates(); ++s) {
int li = map.getLabelIndex(s);
if (li != StateLabelMap.START_LABEL) {
double gammaProb = Math.exp(gammas[ip+1][s]);
for (int j = 0; j < cache.size(); j++) {
constraints.get(cache.getQuick(j)).incrementExpectation(li,gammaProb);
}
}
}
}
}
}
示例3: computeExpectations
import cc.mallet.types.FeatureVectorSequence; //导入方法依赖的package包/类
public void computeExpectations(ArrayList<SumLattice> lattices) {
double[][] gammas;
TIntArrayList cache = new TIntArrayList();
for (int i = 0; i < lattices.size(); i++) {
if (lattices.get(i) == null) { continue; }
SumLattice lattice = lattices.get(i);
FeatureVectorSequence fvs = (FeatureVectorSequence)lattice.getInput();
gammas = lattice.getGammas();
for (int ip = 0; ip < fvs.size(); ++ip) {
cache.resetQuick();
FeatureVector fv = fvs.getFeatureVector(ip);
int fi;
for (int loc = 0; loc < fv.numLocations(); loc++) {
fi = fv.indexAtLocation(loc);
// binary constraint features
if (constraints.containsKey(fi)) {
cache.add(fi);
}
}
if (constraints.containsKey(fv.getAlphabet().size())) {
cache.add(fv.getAlphabet().size());
}
for (int s = 0; s < map.getNumStates(); ++s) {
int li = map.getLabelIndex(s);
if (li != StateLabelMap.START_LABEL) {
double gammaProb = Math.exp(gammas[ip+1][s]);
for (int j = 0; j < cache.size(); j++) {
constraints.get(cache.getQuick(j)).expectation[li] += gammaProb;
}
}
}
}
}
}
示例4: convert
import cc.mallet.types.FeatureVectorSequence; //导入方法依赖的package包/类
/**
*
* @param inst input instance, with FeatureVectorSequence as data.
* @param alphabetsPipe a Noop pipe containing the data and target alphabets for
* the resulting InstanceList and AugmentableFeatureVectors
* @return list of instances, each with one AugmentableFeatureVector as data
*/
public static InstanceList convert(Instance inst, Noop alphabetsPipe)
{
InstanceList ret = new InstanceList(alphabetsPipe);
Object obj = inst.getData();
assert(obj instanceof FeatureVectorSequence);
FeatureVectorSequence fvs = (FeatureVectorSequence) obj;
LabelSequence ls = (LabelSequence) inst.getTarget();
assert(fvs.size() == ls.size());
Object instName = (inst.getName() == null ? "NONAME" : inst.getName());
for (int j = 0; j < fvs.size(); j++) {
FeatureVector fv = fvs.getFeatureVector(j);
int[] indices = fv.getIndices();
FeatureVector data = new AugmentableFeatureVector (alphabetsPipe.getDataAlphabet(),
indices, fv.getValues(), indices.length);
Labeling target = ls.getLabelAtPosition(j);
String name = instName.toString() + "[email protected]_POS_" + (j + 1);
Object source = inst.getSource();
Instance toAdd = alphabetsPipe.pipe(new Instance(data, target, name, source));
ret.add(toAdd);
}
return ret;
}
示例5: computeExpectations
import cc.mallet.types.FeatureVectorSequence; //导入方法依赖的package包/类
public void computeExpectations(ArrayList<SumLattice> lattices) {
double[][][] xis;
IntArrayList cache = new IntArrayList();
for (int i = 0; i < lattices.size(); i++) {
if (lattices.get(i) == null) { continue; }
FeatureVectorSequence fvs = (FeatureVectorSequence)lattices.get(i).getInput();
SumLattice lattice = lattices.get(i);
xis = lattice.getXis();
for (int ip = 1; ip < fvs.size(); ++ip) {
cache.clear();
FeatureVector fv = fvs.getFeatureVector(ip);
int fi;
for (int loc = 0; loc < fv.numLocations(); loc++) {
fi = fv.indexAtLocation(loc);
// binary constraint features
if (constraintsMap.containsKey(fi)) {
cache.add(constraintsMap.get(fi));
}
}
for (int prev = 0; prev < map.getNumStates(); ++prev) {
int liPrev = map.getLabelIndex(prev);
if (liPrev != StateLabelMap.START_LABEL) {
for (int curr = 0; curr < map.getNumStates(); ++curr) {
int liCurr = map.getLabelIndex(curr);
if (liCurr != StateLabelMap.START_LABEL) {
double prob = Math.exp(xis[ip][prev][curr]);
for (int j = 0; j < cache.size(); j++) {
constraintsList.get(cache.get(j)).expectation[liPrev][liCurr] += prob;
}
}
}
}
}
}
}
}
示例6: computeExpectations
import cc.mallet.types.FeatureVectorSequence; //导入方法依赖的package包/类
public void computeExpectations(ArrayList<SumLattice> lattices) {
double[][] gammas;
IntArrayList cache = new IntArrayList();
for (int i = 0; i < lattices.size(); i++) {
if (lattices.get(i) == null) { continue; }
SumLattice lattice = lattices.get(i);
FeatureVectorSequence fvs = (FeatureVectorSequence)lattice.getInput();
gammas = lattice.getGammas();
for (int ip = 0; ip < fvs.size(); ++ip) {
cache.clear();
FeatureVector fv = fvs.getFeatureVector(ip);
int fi;
for (int loc = 0; loc < fv.numLocations(); loc++) {
fi = fv.indexAtLocation(loc);
// binary constraint features
if (constraints.containsKey(fi)) {
cache.add(fi);
}
}
if (constraints.containsKey(fv.getAlphabet().size())) {
cache.add(fv.getAlphabet().size());
}
for (int s = 0; s < map.getNumStates(); ++s) {
int li = map.getLabelIndex(s);
if (li != StateLabelMap.START_LABEL) {
double gammaProb = Math.exp(gammas[ip+1][s]);
for (int j = 0; j < cache.size(); j++) {
constraints.get(cache.get(j)).incrementExpectation(li,gammaProb);
}
}
}
}
}
}
示例7: computeExpectations
import cc.mallet.types.FeatureVectorSequence; //导入方法依赖的package包/类
public void computeExpectations(ArrayList<SumLattice> lattices) {
double[][] gammas;
IntArrayList cache = new IntArrayList();
for (int i = 0; i < lattices.size(); i++) {
if (lattices.get(i) == null) { continue; }
SumLattice lattice = lattices.get(i);
FeatureVectorSequence fvs = (FeatureVectorSequence)lattice.getInput();
gammas = lattice.getGammas();
for (int ip = 0; ip < fvs.size(); ++ip) {
cache.clear();
FeatureVector fv = fvs.getFeatureVector(ip);
int fi;
for (int loc = 0; loc < fv.numLocations(); loc++) {
fi = fv.indexAtLocation(loc);
// binary constraint features
if (constraints.containsKey(fi)) {
cache.add(fi);
}
}
if (constraints.containsKey(fv.getAlphabet().size())) {
cache.add(fv.getAlphabet().size());
}
for (int s = 0; s < map.getNumStates(); ++s) {
int li = map.getLabelIndex(s);
if (li != StateLabelMap.START_LABEL) {
double gammaProb = Math.exp(gammas[ip+1][s]);
for (int j = 0; j < cache.size(); j++) {
constraints.get(cache.get(j)).expectation[li] += gammaProb;
}
}
}
}
}
}