public List<SequencePairAlignment<Object,Object>> bestOutputAlignments (int n) { if (outputAlignmentCache != null && outputAlignmentCache.size() >= n) return outputAlignmentCache; bestViterbiNodeSequences(n); // ensure that viterbiNodeAlignmentCache has at least size n ArrayList<SequencePairAlignment<Object,Object>> ret = new ArrayList<SequencePairAlignment<Object,Object>>(n); for (int i = 0; i < n && i < viterbiNodeAlignmentCache.size(); i++) { Object[] ss = new Object[latticeLength-1]; Sequence<ViterbiNode> vs = viterbiNodeAlignmentCache.get(i).output(); for (int j = 0; j < latticeLength-1; j++) ss[j] = vs.get(j+1).output; // Here is where we grab the output from the ViterbiNode destination ret.add(new SequencePairAlignment<Object,Object>(input, new ArraySequence<Object>(ss), viterbiNodeAlignmentCache.get(i).getWeight())); } outputAlignmentCache = ret; return ret; }
public List<SequencePairAlignment<Object,Object>> bestOutputAlignments (int n) { if (outputAlignmentCache != null && outputAlignmentCache.size() >= n) return outputAlignmentCache; bestViterbiNodeSequences(n); // ensure that viterbiNodeAlignmentCache has at least size n ArrayList<SequencePairAlignment<Object,Object>> ret = new ArrayList<SequencePairAlignment<Object,Object>>(n); for (int i = 0; i < n; i++) { Object[] ss = new Object[latticeLength-1]; Sequence<ViterbiNode> vs = viterbiNodeAlignmentCache.get(i).output(); for (int j = 0; j < latticeLength-1; j++) ss[j] = vs.get(j+1).output; // Here is where we grab the output from the ViterbiNode destination ret.add(new SequencePairAlignment<Object,Object>(input, new ArraySequence<Object>(ss), viterbiNodeAlignmentCache.get(i).getWeight())); } outputAlignmentCache = ret; return ret; }
public List<SequencePairAlignment<Object,Object>> bestOutputAlignments (int n) { if (outputAlignmentCache != null && outputAlignmentCache.size() >= n) return outputAlignmentCache; bestViterbiNodeSequences(n); // ensure that viterbiNodeAlignmentCache has at least size n ArrayList<SequencePairAlignment<Object,Object>> ret = new ArrayList<SequencePairAlignment<Object,Object>>(n); for (int i = 0; i < n; i++) { Object[] ss = new Object[latticeLength-1]; Sequence<ViterbiNode> vs = viterbiNodeAlignmentCache.get(i).output(); for (int j = 0; j < latticeLength-1; j++) ss[j] = vs.get(j+1).output; // Here is where we grab the output from the ViterbiNode destination ret.add(new SequencePairAlignment<Object,Object>(input, new ArraySequence<Object>(ss), viterbiNodeAlignmentCache.get(i).getWeight())); } outputAlignmentCache = ret; return ret; }
/** * Perform the backward pass of Viterbi, returning the n-best sequences of * States. Note that the length of each State Sequence is inputLength+1, * because the first element of the sequence is the start state, and the first * input/output symbols occur on the transition from a start state to the next * state. The last State in the sequence corresponds to the final state. */ public List<SequencePairAlignment<Object,State>> bestStateAlignments (int n) { if (stateAlignmentCache != null && stateAlignmentCache.size() >= n) return stateAlignmentCache; bestViterbiNodeSequences(n); // ensure that viterbiNodeAlignmentCache has at least size n ArrayList<SequencePairAlignment<Object,State>> ret = new ArrayList<SequencePairAlignment<Object,State>>(n); for (int i = 0; i < n && i < viterbiNodeAlignmentCache.size(); i++) { State[] ss = new State[latticeLength]; Sequence<ViterbiNode> vs = viterbiNodeAlignmentCache.get(i).output(); for (int j = 0; j < latticeLength; j++) ss[j] = vs.get(j).state; // Here is where we grab the state from the ViterbiNode ret.add(new SequencePairAlignment<Object,State>(input, new ArraySequence<State>(ss), viterbiNodeAlignmentCache.get(i).getWeight())); } stateAlignmentCache = ret; return ret; }
/** * Perform the backward pass of Viterbi, returning the n-best sequences of * States. Note that the length of each State Sequence is inputLength+1, * because the first element of the sequence is the start state, and the first * input/output symbols occur on the transition from a start state to the next * state. The last State in the sequence corresponds to the final state. */ public List<SequencePairAlignment<Object,State>> bestStateAlignments (int n) { if (stateAlignmentCache != null && stateAlignmentCache.size() >= n) return stateAlignmentCache; bestViterbiNodeSequences(n); // ensure that viterbiNodeAlignmentCache has at least size n ArrayList<SequencePairAlignment<Object,State>> ret = new ArrayList<SequencePairAlignment<Object,State>>(n); for (int i = 0; i < n; i++) { State[] ss = new State[latticeLength]; Sequence<ViterbiNode> vs = viterbiNodeAlignmentCache.get(i).output(); for (int j = 0; j < latticeLength; j++) ss[j] = vs.get(j).state; // Here is where we grab the state from the ViterbiNode ret.add(new SequencePairAlignment<Object,State>(input, new ArraySequence<State>(ss), viterbiNodeAlignmentCache.get(i).getWeight())); } stateAlignmentCache = ret; return ret; }
/** * Perform the backward pass of Viterbi, returning the n-best sequences of * States. Note that the length of each State Sequence is inputLength+1, * because the first element of the sequence is the start state, and the first * input/output symbols occur on the transition from a start state to the next * state. The last State in the sequence corresponds to the final state. */ public List<SequencePairAlignment<Object,State>> bestStateAlignments (int n) { if (stateAlignmentCache != null && stateAlignmentCache.size() >= n) return stateAlignmentCache; bestViterbiNodeSequences(n); // ensure that viterbiNodeAlignmentCache has at least size n ArrayList<SequencePairAlignment<Object,State>> ret = new ArrayList<SequencePairAlignment<Object,State>>(n); for (int i = 0; i < n; i++) { State[] ss = new State[latticeLength]; Sequence<ViterbiNode> vs = viterbiNodeAlignmentCache.get(i).output(); for (int j = 0; j < latticeLength; j++) ss[j] = vs.get(j).state; // Here is where we grab the state from the ViterbiNode ret.add(new SequencePairAlignment<Object,State>(input, new ArraySequence<State>(ss), viterbiNodeAlignmentCache.get(i).getWeight())); } stateAlignmentCache = ret; return ret; }
SequencePairAlignment<Object,ViterbiNode> viterbiNodeAlignment = this.bestViterbiNodeSequences(1).get(0); int sequenceLength = viterbiNodeAlignment.output().size(); assert (sequenceLength == viterbiNodeAlignment.input().size()); // Not sure this works for unequal input/output lengths
SequencePairAlignment<Object,ViterbiNode> viterbiNodeAlignment = this.bestViterbiNodeSequences(1).get(0); int sequenceLength = viterbiNodeAlignment.output().size(); assert (sequenceLength == viterbiNodeAlignment.input().size()); // Not sure this works for unequal input/output lengths
SequencePairAlignment<Object,ViterbiNode> viterbiNodeAlignment = this.bestViterbiNodeSequences(1).get(0); int sequenceLength = viterbiNodeAlignment.output().size(); assert (sequenceLength == viterbiNodeAlignment.input().size()); // Not sure this works for unequal input/output lengths