crf.getState(i).setInitialWeight (Transducer.IMPOSSIBLE_WEIGHT); crf.getState("O").setInitialWeight(0.0);
double initialWeight = t.getState(i).getInitialWeight(); TransitionIterator iter = s.transitionIterator (input, ip, output, ip); if (logger.isLoggable (Level.FINE)) logger.fine (" Starting Forward transition iteration from state " + s.getName() + " on input " + input.get(ip).toString() + " and output " + (output==null ? "(null)" : output.get(ip).toString())); if (ip+1 < constraints.length && constraints[ip+1] > 0 && ((constraints[ip+1]-1) != destination.getIndex())) { logger.fine ("Destination state does not match positive constraint. Assigning -infinite weight. position="+(ip+1)+", constraint="+(constraints[ip+1]-1)+", source ="+i+", destination="+destination.getIndex()); legalTransition = false; else if (((ip+1) < constraints.length) && constraints[ip+1] < 0 && (-(constraints[ip+1]+1) == destination.getIndex())) { logger.fine ("Destination state does not match negative constraint. Assigning -infinite weight. position="+(ip+1)+", constraint="+(constraints[ip+1]+1)+", destination="+destination.getIndex()); legalTransition = false; +"][source="+s.getName() +"][dest="+destination.getName()+"]"); LatticeNode destinationNode = getLatticeNode (ip+1, destination.getIndex()); destinationNode.output = iter.getOutput(); double transitionWeight = iter.getWeight(); logger.fine ("Set alpha of latticeNode at ip = "+ (ip+1) + " stateIndex = " + destination.getIndex() + ", destinationNode.alpha = " + destinationNode.alpha); logger.fine ("Illegal transition from state " + i + " to state " + destination.getIndex() + ". Setting alpha to Inf"); if (constraints[latticeLength-1] < 0 && -i == constraints[latticeLength-1]+1) continue;
boolean atLeastOneInitialState = false; for (int i = 0; i < numStates; i++) { double initialWeight = t.getState(i).getInitialWeight(); if (logger.isLoggable (Level.FINE)) logger.fine (" Starting Foward transition iteration from state " + s.getName() + " on input " + input.get(ip).toString() + " and output " + (output==null ? "(null)" : output.get(ip).toString())); State destination = iter.nextState(); if (logger.isLoggable (Level.FINE)) logger.fine ("Forward Lattice[inputPos="+ip+"][source="+s.getName()+"][dest="+destination.getName()+"]"); LatticeNode destinationNode = getLatticeNode (ip+1, destination.getIndex()); destinationNode.output = iter.getOutput(); double transitionWeight = iter.getWeight(); totalWeight = Transducer.sumLogProb (totalWeight, (nodes[latticeLength-1][i].alpha + t.getState(i).getFinalWeight())); if (nodes[latticeLength-1][i] != null) { State s = t.getState(i); nodes[latticeLength-1][i].beta = s.getFinalWeight(); gammas[latticeLength-1][i] = nodes[latticeLength-1][i].alpha + nodes[latticeLength-1][i].beta - totalWeight; if (incrementor != null) { State destination = iter.nextState(); if (logger.isLoggable (Level.FINE)) logger.fine ("Backward Lattice[inputPos="+ip+"][source="+s.getName()+"][dest="+destination.getName()+"]"); int j = destination.getIndex();
boolean atLeastOneInitialState = false; for (int i = 0; i < numStates; i++) { double initialWeight = t.getState(i).getInitialWeight(); if (logger.isLoggable (Level.FINE)) logger.fine (" Starting Foward transition iteration from state " + s.getName() + " on input " + input.get(ip).toString() + " and output " + (output==null ? "(null)" : output.get(ip).toString())); State destination = iter.nextState(); if (logger.isLoggable (Level.FINE)) logger.fine ("Forward Lattice[inputPos="+ip+"][source="+s.getName()+"][dest="+destination.getName()+"]"); LatticeNode destinationNode = getLatticeNode (ip+1, destination.getIndex()); destinationNode.output = iter.getOutput(); double transitionWeight = iter.getWeight(); totalWeight = Transducer.sumLogProb (totalWeight, (nodes[latticeLength-1][i].alpha + t.getState(i).getFinalWeight())); if (nodes[latticeLength-1][i] != null) { State s = t.getState(i); nodes[latticeLength-1][i].beta = s.getFinalWeight(); gammas[latticeLength-1][i] = nodes[latticeLength-1][i].alpha + nodes[latticeLength-1][i].beta - totalWeight; if (incrementor != null) { State destination = iter.nextState(); if (logger.isLoggable (Level.FINE)) logger.fine ("Backward Lattice[inputPos="+ip+"][source="+s.getName()+"][dest="+destination.getName()+"]"); int j = destination.getIndex();
boolean atLeastOneInitialState = false; for (int i = 0; i < numStates; i++) { double initialWeight = t.getState(i).getInitialWeight(); if (logger.isLoggable (Level.FINE)) logger.fine (" Starting Foward transition iteration from state " + s.getName() + " on input " + input.get(ip).toString() + " and output " + (output==null ? "(null)" : output.get(ip).toString())); State destination = iter.nextState(); if (logger.isLoggable (Level.FINE)) logger.fine ("Forward Lattice[inputPos="+ip+"][source="+s.getName()+"][dest="+destination.getName()+"]"); LatticeNode destinationNode = getLatticeNode (ip+1, destination.getIndex()); destinationNode.output = iter.getOutput(); double transitionWeight = iter.getWeight(); totalWeight = Transducer.sumLogProb (totalWeight, (nodes[latticeLength-1][i].alpha + t.getState(i).getFinalWeight())); if (nodes[latticeLength-1][i] != null) { State s = t.getState(i); nodes[latticeLength-1][i].beta = s.getFinalWeight(); gammas[latticeLength-1][i] = nodes[latticeLength-1][i].alpha + nodes[latticeLength-1][i].beta - totalWeight; if (incrementor != null) { State destination = iter.nextState(); if (logger.isLoggable (Level.FINE)) logger.fine ("Backward Lattice[inputPos="+ip+"][source="+s.getName()+"][dest="+destination.getName()+"]"); int j = destination.getIndex();
boolean atLeastOneInitialState = false; for (int i = 0; i < numStates; i++) { double initialWeight = t.getState(i).getInitialWeight(); TransitionIterator iter = s.transitionIterator (input, ip, output, ip); if (logger.isLoggable (Level.FINE)) logger.fine (" Starting Foward transition iteration from state " + s.getName() + " on input " + input.get(ip).toString() + " and output " + (output==null ? "(null)" : output.get(ip).toString())); State destination = iter.nextState(); if (logger.isLoggable (Level.FINE)) logger.fine ("Forward Lattice[inputPos="+ip+"][source="+s.getName()+"][dest="+destination.getName()+"]"); LatticeNode destinationNode = getLatticeNode (ip+1, destination.getIndex()); destinationNode.output = iter.getOutput(); double transitionWeight = iter.getWeight(); totalWeight = Transducer.sumLogProb (totalWeight, (nodes[latticeLength-1][i].alpha + t.getState(i).getFinalWeight())); if (nodes[latticeLength-1][i] != null) { State s = t.getState(i); nodes[latticeLength-1][i].beta = s.getFinalWeight(); gammas[latticeLength-1][i] = nodes[latticeLength-1][i].alpha + nodes[latticeLength-1][i].beta - totalWeight; if (incrementor != null) { TransitionIterator iter = s.transitionIterator (input, ip, output, ip); while (iter.hasNext()) { State destination = iter.nextState();
boolean atLeastOneInitialState = false; for (int i = 0; i < numStates; i++) { double initialWeight = t.getState(i).getInitialWeight(); TransitionIterator iter = s.transitionIterator (input, ip, output, ip); if (logger.isLoggable (Level.FINE)) logger.fine (" Starting Foward transition iteration from state " + s.getName() + " on input " + input.get(ip).toString() + " and output " + (output==null ? "(null)" : output.get(ip).toString())); State destination = iter.nextState(); if (logger.isLoggable (Level.FINE)) logger.fine ("Forward Lattice[inputPos="+ip+"][source="+s.getName()+"][dest="+destination.getName()+"]"); LatticeNode destinationNode = getLatticeNode (ip+1, destination.getIndex()); destinationNode.output = iter.getOutput(); double transitionWeight = iter.getWeight(); totalWeight = Transducer.sumLogProb (totalWeight, (nodes[latticeLength-1][i].alpha + t.getState(i).getFinalWeight())); if (nodes[latticeLength-1][i] != null) { State s = t.getState(i); nodes[latticeLength-1][i].beta = s.getFinalWeight(); gammas[latticeLength-1][i] = nodes[latticeLength-1][i].alpha + nodes[latticeLength-1][i].beta - totalWeight; if (incrementor != null) { TransitionIterator iter = s.transitionIterator (input, ip, output, ip); while (iter.hasNext()) { State destination = iter.nextState();
boolean atLeastOneInitialState = false; for (int i = 0; i < numStates; i++) { double initialWeight = t.getState(i).getInitialWeight(); TransitionIterator iter = s.transitionIterator (input, ip, output, ip); if (logger.isLoggable (Level.FINE)) logger.fine (" Starting Foward transition iteration from state " + s.getName() + " on input " + input.get(ip).toString() + " and output " + (output==null ? "(null)" : output.get(ip).toString())); State destination = iter.nextState(); if (logger.isLoggable (Level.FINE)) logger.fine ("Forward Lattice[inputPos="+ip+"][source="+s.getName()+"][dest="+destination.getName()+"]"); LatticeNode destinationNode = getLatticeNode (ip+1, destination.getIndex()); destinationNode.output = iter.getOutput(); double transitionWeight = iter.getWeight(); totalWeight = Transducer.sumLogProb (totalWeight, (nodes[latticeLength-1][i].alpha + t.getState(i).getFinalWeight())); if (nodes[latticeLength-1][i] != null) { State s = t.getState(i); nodes[latticeLength-1][i].beta = s.getFinalWeight(); gammas[latticeLength-1][i] = nodes[latticeLength-1][i].alpha + nodes[latticeLength-1][i].beta - totalWeight; if (incrementor != null) { TransitionIterator iter = s.transitionIterator (input, ip, output, ip); while (iter.hasNext()) { State destination = iter.nextState();
crf.getState(i).setInitialWeight (Transducer.IMPOSSIBLE_WEIGHT); crf.getState("O").setInitialWeight(0.0);
double initialWeight = transducer.getState(i).getInitialWeight(); if (initialWeight > Transducer.IMPOSSIBLE_WEIGHT) { getLatticeNode(0, i).alpha = initialWeight; while (iter.hasNext()) { State destination = iter.next(); LatticeNode destinationNode = getLatticeNode(ip + 1, destination.getIndex()); destinationNode.output = iter.getOutput(); double transitionWeight = iter.getWeight(); if (nodes[latticeLength-1][i] != null) { totalWeight = Transducer.sumLogProb(totalWeight, (nodes[latticeLength-1][i].alpha + transducer.getState(i).getFinalWeight())); if (nodes[latticeLength - 1][i] != null) { State s = transducer.getState(i); nodes[latticeLength - 1][i].beta = s.getFinalWeight(); gammas[latticeLength - 1][i] = nodes[latticeLength - 1][i].alpha + nodes[latticeLength - 1][i].beta - totalWeight; while (iter.hasNext()) { State destination = iter.next(); int j = destination.getIndex(); LatticeNode destinationNode = nodes[ip + 1][j]; if (destinationNode != null) {
boolean atLeastOneInitialState = false; for (int i = 0; i < numStates; i++) { double initialWeight = t.getState(i).getInitialWeight(); if (initialWeight > Transducer.IMPOSSIBLE_WEIGHT) { getLatticeNode(0, i).alpha = Math.exp(initialWeight); continue; State s = t.getState(i); TransitionIterator iter = s.transitionIterator(input, ip, output, ip); while (iter.hasNext()) { State destination = iter.next(); LatticeNode destinationNode = getLatticeNode(ip + 1, destination.getIndex()); if (Double.isNaN(destinationNode.alpha)) destinationNode.alpha = 0; Z = 0; Z += nodes[latticeLength - 1][i].alpha * Math.exp(t.getState(i).getFinalWeight()); if (nodes[latticeLength - 1][i] != null) { State s = t.getState(i); nodes[latticeLength - 1][i].beta = Math.exp(s.getFinalWeight()); double gamma = nodes[latticeLength - 1][i].alpha * nodes[latticeLength - 1][i].beta / Z; continue; State s = t.getState(i);
double initialWeight = transducer.getState(i).getInitialWeight(); if (initialWeight > Transducer.IMPOSSIBLE_WEIGHT) { getLatticeNode(0, i).alpha = initialWeight; while (iter.hasNext()) { State destination = iter.next(); LatticeNode destinationNode = getLatticeNode(ip + 1, destination.getIndex()); destinationNode.output = iter.getOutput(); double transitionWeight = iter.getWeight(); if (nodes[latticeLength-1][i] != null) { totalWeight = Transducer.sumLogProb(totalWeight, (nodes[latticeLength-1][i].alpha + transducer.getState(i).getFinalWeight())); if (nodes[latticeLength - 1][i] != null) { State s = transducer.getState(i); nodes[latticeLength - 1][i].beta = s.getFinalWeight(); gammas[latticeLength - 1][i] = nodes[latticeLength - 1][i].alpha + nodes[latticeLength - 1][i].beta - totalWeight; while (iter.hasNext()) { State destination = iter.next(); int j = destination.getIndex(); LatticeNode destinationNode = nodes[ip + 1][j]; if (destinationNode != null) {
boolean atLeastOneInitialState = false; for (int i = 0; i < numStates; i++) { double initialWeight = t.getState(i).getInitialWeight(); if (initialWeight > Transducer.IMPOSSIBLE_WEIGHT) { getLatticeNode(0, i).alpha = Math.exp(initialWeight); continue; State s = t.getState(i); TransitionIterator iter = s.transitionIterator(input, ip, output, ip); while (iter.hasNext()) { State destination = iter.next(); LatticeNode destinationNode = getLatticeNode(ip + 1, destination.getIndex()); if (Double.isNaN(destinationNode.alpha)) destinationNode.alpha = 0; Z = 0; Z += nodes[latticeLength - 1][i].alpha * Math.exp(t.getState(i).getFinalWeight()); if (nodes[latticeLength - 1][i] != null) { State s = t.getState(i); nodes[latticeLength - 1][i].beta = Math.exp(s.getFinalWeight()); double gamma = nodes[latticeLength - 1][i].alpha * nodes[latticeLength - 1][i].beta / Z; continue; State s = t.getState(i);
boolean atLeastOneInitialState = false; for (int i = 0; i < numStates; i++) { double initialWeight = t.getState(i).getInitialWeight(); if (initialWeight > Transducer.IMPOSSIBLE_WEIGHT) { getLatticeNode(0, i).alpha = Math.exp(initialWeight); continue; State s = t.getState(i); TransitionIterator iter = s.transitionIterator(input, ip, output, ip); while (iter.hasNext()) { State destination = iter.next(); LatticeNode destinationNode = getLatticeNode(ip + 1, destination.getIndex()); if (Double.isNaN(destinationNode.alpha)) destinationNode.alpha = 0; Z = 0; Z += nodes[latticeLength - 1][i].alpha * Math.exp(t.getState(i).getFinalWeight()); if (nodes[latticeLength - 1][i] != null) { State s = t.getState(i); nodes[latticeLength - 1][i].beta = Math.exp(s.getFinalWeight()); double gamma = nodes[latticeLength - 1][i].alpha * nodes[latticeLength - 1][i].beta / Z; continue; State s = t.getState(i);
double initialWeight = transducer.getState(i).getInitialWeight(); if (initialWeight > Transducer.IMPOSSIBLE_WEIGHT) { getLatticeNode(0, i).alpha = initialWeight; while (iter.hasNext()) { State destination = iter.next(); LatticeNode destinationNode = getLatticeNode(ip + 1, destination.getIndex()); destinationNode.output = iter.getOutput(); double transitionWeight = iter.getWeight(); if (nodes[latticeLength-1][i] != null) { totalWeight = Transducer.sumLogProb(totalWeight, (nodes[latticeLength-1][i].alpha + transducer.getState(i).getFinalWeight())); if (nodes[latticeLength - 1][i] != null) { State s = transducer.getState(i); nodes[latticeLength - 1][i].beta = s.getFinalWeight(); gammas[latticeLength - 1][i] = nodes[latticeLength - 1][i].alpha + nodes[latticeLength - 1][i].beta - totalWeight; while (iter.hasNext()) { State destination = iter.next(); int j = destination.getIndex(); LatticeNode destinationNode = nodes[ip + 1][j]; if (destinationNode != null) {
connected); for (int i = 0; i < crf.numStates(); i++) crf.getState(i).setInitialWeight (Transducer.IMPOSSIBLE_WEIGHT); crf.getState(startName).setInitialWeight(0.0);
connected); for (int i = 0; i < crf.numStates(); i++) crf.getState(i).setInitialWeight (Transducer.IMPOSSIBLE_WEIGHT); crf.getState(startName).setInitialWeight(0.0);
connected); for (int i = 0; i < crf.numStates(); i++) crf.getState(i).setInitialWeight (Transducer.IMPOSSIBLE_WEIGHT); crf.getState(startName).setInitialWeight(0.0);
boolean anyInitialState = false; for (int i = 0; i < numStates; i++) { double initialWeight = t.getState(i).getInitialWeight(); if (initialWeight > Transducer.IMPOSSIBLE_WEIGHT) { ViterbiNode n = getViterbiNode (0, i); continue; State s = t.getState(i); TransitionIterator iter = s.transitionIterator (input, ip, providedOutput, ip); if (logger.isLoggable (Level.FINE)) logger.fine (" Starting Viterbi transition iteration from state " + s.getName() + " on input " + input.get(ip)); while (iter.hasNext()) { State destination = iter.next(); if (logger.isLoggable (Level.FINE)) logger.fine ("Viterbi[inputPos="+ip +"][source="+s.getName() +"][dest="+destination.getName()+"]"); ViterbiNode destinationNode = getViterbiNode (ip+1, destination.getIndex()); destinationNode.output = iter.getOutput(); double weight = lattice[ip][i].delta + iter.getWeight(); if (ip == latticeLength-2) { weight += destination.getFinalWeight(); +"][source][dest="+destination.getName() +"] weight increased to "+weight+" by source="+ s.getName()); destinationNode.delta = weight; destinationNode.maxWeightPredecessor = lattice[ip][i];
boolean anyInitialState = false; for (int i = 0; i < numStates; i++) { double initialWeight = t.getState(i).getInitialWeight(); if (initialWeight > Transducer.IMPOSSIBLE_WEIGHT) { ViterbiNode n = getViterbiNode (0, i); continue; State s = t.getState(i); TransitionIterator iter = s.transitionIterator (input, ip, providedOutput, ip); if (logger.isLoggable (Level.FINE)) logger.fine (" Starting Viterbi transition iteration from state " + s.getName() + " on input " + input.get(ip)); while (iter.hasNext()) { State destination = iter.next(); if (logger.isLoggable (Level.FINE)) logger.fine ("Viterbi[inputPos="+ip +"][source="+s.getName() +"][dest="+destination.getName()+"]"); ViterbiNode destinationNode = getViterbiNode (ip+1, destination.getIndex()); destinationNode.output = iter.getOutput(); double weight = lattice[ip][i].delta + iter.getWeight(); if (ip == latticeLength-2) { weight += destination.getFinalWeight(); +"][source][dest="+destination.getName() +"] weight increased to "+weight+" by source="+ s.getName()); destinationNode.delta = weight; destinationNode.maxWeightPredecessor = lattice[ip][i];