Package cc.mallet.fst

Examples of cc.mallet.fst.MaxLatticeDefault$ViterbiNode


    if (k == 1) {
      answers = new Sequence[1];
      answers[0] = model.transduce (input);
    }
    else {
      MaxLatticeDefault lattice =
              new MaxLatticeDefault (model, input, null, cacheSizeOption.value());

      answers = lattice.bestOutputSequences(k).toArray(new Sequence[0]);
    }
    return answers;
  }
View Full Code Here


    if (showLattice == true) {
      CRF crf = extor.getCrf();
      // xxx perhaps the next two lines could be a transducer method???
      Instance carrier = extor.getFeaturePipe().pipe(new Instance (input, null, null, null));
      info.fvs = (FeatureVectorSequence) carrier.getData ();
      info.lattice = new MaxLatticeDefault (crf, (Sequence) carrier.getData(), null);
      info.bestStates = info.lattice.bestOutputSequence();
    }

    return info;
  }
View Full Code Here

    assertTrue (lattice.getTotalWeight() == seqWeight);
  }

  public void testViterbi ()
  {
    double weight = new MaxLatticeDefault (transducer, seq).bestWeight();
    System.out.println ("weight = "+weight);
    assertTrue (weight == seqWeight);
  }
View Full Code Here

            new FeatureVector((Alphabet) crf.getInputAlphabet(),
                new double[] { 1 }),
            new FeatureVector((Alphabet) crf.getInputAlphabet(),
                new double[] { 1 }), });

    MaxLattice lattice = new MaxLatticeDefault(crf, fvs);
    Sequence<Transducer.State> viterbiPath = lattice.bestStateSequence();
    // We start in state0
    assertTrue(viterbiPath.get(0) == crf.getState(0));
    // We go to state1
    assertTrue(viterbiPath.get(1) == crf.getState(1));
    // And on through a self-transition to state1 again
View Full Code Here

    CRFTrainerByLabelLikelihood crft = new CRFTrainerByLabelLikelihood(crf);
    crft.trainIncremental(training);

    // Check that the notstart state is used at test time
    Sequence input = (Sequence) training.get(0).getData();
    Sequence output = new MaxLatticeDefault(crf, input)
        .bestOutputSequence();

    boolean notstartFound = false;
    for (int i = 0; i < output.size(); i++) {
      if (output.get(i).toString().equals("notstart")) {
        notstartFound = true;
      }
    }
    System.err.println(output.toString());
    assertTrue(notstartFound);

    // Now add -infinite weight onto a transition, and make sure that it's
    // honored.
    CRF.State state = crf.getState("notstart");
    int widx = crf.getWeightsIndex("BadBad");
    int numFeatures = crf.getInputAlphabet().size();
    SparseVector w = new SparseVector(new double[numFeatures]);
    w.setAll(Double.NEGATIVE_INFINITY);
    crf.setWeights(widx, w);

    state.addWeight(0, "BadBad");
    state.addWeight(1, "BadBad");

    // Verify that this effectively prevents the notstart state from being
    // used
    output = new MaxLatticeDefault(crf, input).bestOutputSequence();
    notstartFound = false;
    for (int i = 0; i < output.size() - 1; i++) {
      if (output.get(i).toString().equals("notstart")) {
        notstartFound = true;
      }
View Full Code Here

TOP

Related Classes of cc.mallet.fst.MaxLatticeDefault$ViterbiNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.