示例#1
0
 public TransitionIterator(
     State source, FeatureSequence inputSeq, int inputPosition, String output, HMM hmm) {
   this.source = source;
   this.hmm = hmm;
   this.inputSequence = inputSeq;
   this.inputFeature = new Integer(inputSequence.getIndexAtPosition(inputPosition));
   this.inputPos = inputPosition;
   this.weights = new double[source.destinations.length];
   for (int transIndex = 0; transIndex < source.destinations.length; transIndex++) {
     if (output == null || output.equals(source.labels[transIndex])) {
       weights[transIndex] = 0;
       // xxx should this be emission of the _next_ observation?
       // double logEmissionProb =
       // hmm.emissionMultinomial[source.getIndex()].logProbability
       // (inputSeq.get (inputPosition));
       int destIndex = source.getDestinationState(transIndex).getIndex();
       double logEmissionProb =
           hmm.emissionMultinomial[destIndex].logProbability(inputSeq.get(inputPosition));
       double logTransitionProb =
           hmm.transitionMultinomial[source.getIndex()].logProbability(
               source.destinationNames[transIndex]);
       // weight = logProbability
       weights[transIndex] = (logEmissionProb + logTransitionProb);
       assert (!Double.isNaN(weights[transIndex]));
     } else weights[transIndex] = IMPOSSIBLE_WEIGHT;
   }
   nextIndex = 0;
   while (nextIndex < source.destinations.length && weights[nextIndex] == IMPOSSIBLE_WEIGHT)
     nextIndex++;
 }
示例#2
0
 public Transducer.State nextState() {
   assert (nextIndex < source.destinations.length);
   index = nextIndex;
   nextIndex++;
   while (nextIndex < source.destinations.length && weights[nextIndex] == IMPOSSIBLE_WEIGHT)
     nextIndex++;
   return source.getDestinationState(index);
 }
示例#3
0
 public Transducer.State getDestinationState() {
   return source.getDestinationState(index);
 }