Package cc.mallet.pipe.iterator

Examples of cc.mallet.pipe.iterator.ArrayIterator


  public void testXis() {
    Pipe p = makeSpacePredictionPipe();

    InstanceList instances = new InstanceList(p);
    instances.addThruPipe(new ArrayIterator(data));

    CRF crf1 = new CRF(p, null);
    crf1.addFullyConnectedStatesForLabels();
    CRFTrainerByLabelLikelihood crft1 = new CRFTrainerByLabelLikelihood(
        crf1);
View Full Code Here


  public void testStateAddWeights() {
    Pipe p = makeSpacePredictionPipe(); // This used to be
    // MEMM.makeSpacePredictionPipe(),
    // but I don't know why -akm 12/2007
    InstanceList training = new InstanceList(p);
    training.addThruPipe(new ArrayIterator(data)); // This used to be
    // MEMM.data, but I
    // don't know why -akm
    // 12/2007

    CRF crf = new CRF(p, null);
View Full Code Here

     Pipe pipe = TestMEMM.makeSpacePredictionPipe ();
     String[] data0 = { TestCRF.data[0] };
     String[] data1 = { TestCRF.data[1] };

     InstanceList training = new InstanceList (pipe);
     training.addThruPipe (new ArrayIterator (data0));
     InstanceList testing = new InstanceList (pipe);
     testing.addThruPipe (new ArrayIterator (data1));

     CRF crf = new CRF (pipe, null);
     crf.addFullyConnectedStatesForLabels ();
     CRFTrainerByLabelLikelihood crft = new CRFTrainerByLabelLikelihood (crf);
     crft.trainIncremental (training);

     CRFExtractor extor = TestLatticeViewer.hackCrfExtor (crf);
     Extraction extraction = extor.extract (new ArrayIterator (data1));

     if (!outputDir.exists ()) outputDir.mkdir ();
     DocumentViewer.writeExtraction (outputDir, extraction);
   }
View Full Code Here

      new Target2LabelSequence (),
      new PrintInputAndTarget (),
    });

    InstanceList pred = new InstanceList (pipe);
    pred.addThruPipe (new ArrayIterator (predStrings));

    InstanceList targets = new InstanceList (pipe);
    targets.addThruPipe (new ArrayIterator (trueStrings));

    LabelAlphabet dict = (LabelAlphabet) pipe.getTargetAlphabet ();
    Extraction extraction = new Extraction (null, dict);

    for (int i = 0; i < pred.size(); i++) {
View Full Code Here

    Pipe pipe = TestMEMM.makeSpacePredictionPipe ();
    String[] data0 = { TestCRF.data[0] };
    String[] data1 = { TestCRF.data[1] };

    InstanceList training = new InstanceList (pipe);
    training.addThruPipe (new ArrayIterator (data0));
    InstanceList testing = new InstanceList (pipe);
    testing.addThruPipe (new ArrayIterator (data1));

    CRF crf = new CRF (pipe, null);
    crf.addFullyConnectedStatesForLabels ();
    CRFTrainerByLabelLikelihood crft = new CRFTrainerByLabelLikelihood (crf);
    crft.trainIncremental (training);

    CRFExtractor extor = hackCrfExtor (crf);
    Extraction extration = extor.extract (new ArrayIterator (data1));

    PrintStream out = new PrintStream (new FileOutputStream (htmlFile));
    LatticeViewer.extraction2html (extration, extor, out);
    out.close();
View Full Code Here

    Pipe pipe = TestMEMM.makeSpacePredictionPipe ();
    String[] data0 = { TestCRF.data[0] };
    String[] data1 = TestCRF.data;

    InstanceList training = new InstanceList (pipe);
    training.addThruPipe (new ArrayIterator (data0));
    InstanceList testing = new InstanceList (pipe);
    testing.addThruPipe (new ArrayIterator (data1));

    CRF crf = new CRF (pipe, null);
    crf.addFullyConnectedStatesForLabels ();
    CRFTrainerByLabelLikelihood crft = new CRFTrainerByLabelLikelihood (crf);
    TokenAccuracyEvaluator eval = new TokenAccuracyEvaluator (new InstanceList[] {training, testing}, new String[] {"Training", "Testing"});
    for (int i = 0; i < 5; i++) {
      crft.train (training, 1);
      eval.evaluate(crft);
    }

    CRFExtractor extor = hackCrfExtor (crf);
    Extraction e1 = extor.extract (new ArrayIterator (data1));

    Pipe pipe2 = TestMEMM.makeSpacePredictionPipe ();
    InstanceList training2 = new InstanceList (pipe2);
    training2.addThruPipe (new ArrayIterator (data0));
    InstanceList testing2 = new InstanceList (pipe2);
    testing2.addThruPipe (new ArrayIterator (data1));

    MEMM memm = new MEMM (pipe2, null);
    memm.addFullyConnectedStatesForLabels ();
    MEMMTrainer memmt = new MEMMTrainer (memm);
    TransducerEvaluator memmeval = new TokenAccuracyEvaluator (new InstanceList[] {training2, testing2}, new String[] {"Training2", "Testing2"});
    memmt.train (training2, 5);
    memmeval.evaluate(memmt);

    CRFExtractor extor2 = hackCrfExtor (memm);
    Extraction e2 = extor2.extract (new ArrayIterator (data1));

    if (!htmlDir.exists ()) htmlDir.mkdir ();
    LatticeViewer.viewDualResults (htmlDir, e1, extor, e2, extor2);

  }
View Full Code Here

              new Target2Label (),
              new CharSequence2TokenSequence (),
              new TokenSequence2FeatureSequence (),
              new FeatureSequence2FeatureVector ()}));

    instances.addThruPipe (new ArrayIterator (africaTraining, "africa"));
    instances.addThruPipe (new ArrayIterator (asiaTraining, "asia"));
    Classifier c = new NaiveBayesTrainer ().train (instances);

    Classification cf = c.classify ("nelson mandela never eats lions");
    assertTrue (cf.getLabeling().getBestLabel()
        == ((LabelAlphabet)instances.getTargetAlphabet()).lookupLabel("africa"));
View Full Code Here

    });

    InstanceList mtLst = new InstanceList (mtPipe);
    InstanceList noMtLst = new InstanceList (noMtPipe);

    mtLst.addThruPipe (new ArrayIterator (doc1));
    noMtLst.addThruPipe (new ArrayIterator (doc1));

    Instance mtInst = mtLst.get (0);
    Instance noMtInst = noMtLst.get (0);

    TokenSequence mtTs = (TokenSequence) mtInst.getData ();
View Full Code Here

            new PrintInputAndTarget (),
    });

    Pipe mtPipe = (Pipe) TestSerializable.cloneViaSerialization (origPipe);
    InstanceList mtLst = new InstanceList (mtPipe);
    mtLst.addThruPipe (new ArrayIterator (doc1));
    Instance mtInst = mtLst.get (0);
    TokenSequence mtTs = (TokenSequence) mtInst.getData ();
    assertEquals (6, mtTs.size ());
    assertEquals (1.0, mtTs.get (3).getFeatureValue ("time"), 1e-15);
    assertEquals (1.0, mtTs.get (4).getFeatureValue ("time"), 1e-15);
View Full Code Here

  {
    Pipe p = makeSpacePredictionPipe ();
    InstanceList training = new InstanceList (p);
//    String[] data = { TestMEMM.data[0], }; // TestMEMM.data[1], TestMEMM.data[2], TestMEMM.data[3], };
//    String[] data = { "ab" };
    training.addThruPipe (new ArrayIterator (data));

//    CRF4 memm = new CRF4 (p, null);
    MEMM memm = new MEMM (p, null);
    memm.addFullyConnectedStatesForLabels ();
    memm.addStartState();
View Full Code Here

TOP

Related Classes of cc.mallet.pipe.iterator.ArrayIterator

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.