本文整理汇总了Java中com.carrotsearch.hppc.IntArrayList.clear方法的典型用法代码示例。如果您正苦于以下问题:Java IntArrayList.clear方法的具体用法?Java IntArrayList.clear怎么用?Java IntArrayList.clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.carrotsearch.hppc.IntArrayList
的用法示例。
在下文中一共展示了IntArrayList.clear方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: State
import com.carrotsearch.hppc.IntArrayList; //导入方法依赖的package包/类
public State(String input) {
stateStack = new Stack<int[]>();
int[] neutral = new int[alphabet.features];
for (int i = 0; i < neutral.length; ++i)
neutral[i] = 0;
stateStack.push(neutral);
outputString = new IntArrayList();
inputString = new IntArrayList();
outputPointer = 0;
inputPointer = 0;
current_weight = 0.0f;
displayVector = new ArrayList<Result>();
IndexString inputLine = new IndexString(input);
while (inputLine.index < input.length()) {
inputString.add(letterTrie.findKey(inputLine));
if (inputString.get(inputString.size() - 1) == HfstOptimizedLookup.NO_SYMBOL_NUMBER) {
inputString.clear();
break;
}
}
inputString.add(HfstOptimizedLookup.NO_SYMBOL_NUMBER);
}
示例2: State
import com.carrotsearch.hppc.IntArrayList; //导入方法依赖的package包/类
public State(String input) {
stateStack = new Stack<int[]>();
int[] neutral = new int[alphabet.features];
for (int i = 0; i < neutral.length; ++i)
neutral[i] = 0;
stateStack.push(neutral);
outputString = new IntArrayList();
inputString = new IntArrayList();
outputPointer = 0;
inputPointer = 0;
displayVector = new ArrayList<Result>();
IndexString inputLine = new IndexString(input);
while (inputLine.index < input.length()) {
inputString.add(letterTrie.findKey(inputLine));
if (inputString.get(inputString.size() - 1) == HfstOptimizedLookup.NO_SYMBOL_NUMBER) {
inputString.clear();
break;
}
}
inputString.add(HfstOptimizedLookup.NO_SYMBOL_NUMBER);
}
示例3: dumbSort
import com.carrotsearch.hppc.IntArrayList; //导入方法依赖的package包/类
private void dumbSort(IntArrayList arrayList) {
int[] tmp = arrayList.toArray();
Arrays.sort(tmp);
arrayList.clear();
for (int tmpval : tmp) {
arrayList.add(tmpval);
}
}
示例4: computeExpectations
import com.carrotsearch.hppc.IntArrayList; //导入方法依赖的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;
}
}
}
}
}
}
}
}
示例5: computeExpectations
import com.carrotsearch.hppc.IntArrayList; //导入方法依赖的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);
}
}
}
}
}
}
示例6: computeExpectations
import com.carrotsearch.hppc.IntArrayList; //导入方法依赖的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;
}
}
}
}
}
}
示例7: linearizeAndCalculateOffsets
import com.carrotsearch.hppc.IntArrayList; //导入方法依赖的package包/类
/**
* Linearize all states, putting <code>states</code> in front of the automaton
* and calculating stable state offsets.
*/
private int linearizeAndCalculateOffsets(FSA fsa, IntArrayList states, IntArrayList linearized,
IntIntHashMap offsets) throws IOException {
final BitSet visited = new BitSet();
final IntStack nodes = new IntStack();
linearized.clear();
/*
* Linearize states with most inlinks first.
*/
for (int i = 0; i < states.size(); i++) {
linearizeState(fsa, nodes, linearized, visited, states.get(i));
}
/*
* Linearize the remaining states by chaining them one after another, in depth-order.
*/
nodes.push(fsa.getRootNode());
while (!nodes.isEmpty()) {
final int node = nodes.pop();
if (visited.get(node))
continue;
linearizeState(fsa, nodes, linearized, visited, node);
}
/*
* Calculate new state offsets. This is iterative. We start with
* maximum potential offsets and recalculate until converged.
*/
int MAX_OFFSET = Integer.MAX_VALUE;
for (IntCursor c : linearized) {
offsets.put(c.value, MAX_OFFSET);
}
int i, j = 0;
while ((i = emitNodes(fsa, null, linearized)) > 0) {
j = i;
}
return j;
}