Package org.fnlp.data.reader

Examples of org.fnlp.data.reader.SequenceReader


    Pipe pipe = createProcessor();

    // 测试集
    testSet = new InstanceSet(pipe);

    testSet.loadThruStagePipes(new SequenceReader(testfile,hasLabel,"utf8"));
    System.out.println("测试样本个数:\t" + testSet.size()); // 样本个数

    long featuretime = System.currentTimeMillis();

View Full Code Here


    features = factory.DefaultFeatureAlphabet();
    features.setStopIncrement(false);
    labels.setStopIncrement(false);

    // 训练集
    trainSet.loadThruStagePipes(new SequenceReader(train, true));

    long endTime = System.currentTimeMillis();
    System.out.println(" done!");
    System.out.println("Time escape: " + (endTime - beginTime) / 1000 + "s");
    System.out.println();
View Full Code Here

        pipe = featurePipe;
      }

      // 测试集
      testSet = new InstanceSet(pipe);
      testSet.loadThruStagePipes(new SequenceReader(testfile, hasTarget, "utf8"));
      System.out.println("Test Number: " + testSet.size()); // 样本个数
    }
  }
View Full Code Here

    System.out.print("读入训练数据 ...");
    InstanceSet trainSet = new InstanceSet(pipe, factory);

    // 训练集
    trainSet.loadThruStagePipes(new SequenceReader(train, true, "utf8"));
    System.out.println("训练样本个数 " + trainSet.size());
    System.out.println("标签个数: " + labels.size()); //
    System.out.println("特征个数" + features.size());

    // 冻结特征集
    features.setStopIncrement(true);
    labels.setStopIncrement(true);


    // viterbi解码
    HammingLoss loss = new HammingLoss();
    Inferencer inference = new LinearViterbi(templets, labels.size());
    Update update = new LinearViterbiPAUpdate((LinearViterbi) inference, loss);


    OnlineTrainer trainer = new OnlineTrainer(inference, update, loss,
        features.size(), 50,0.1f);

    Linear cl = trainer.train(trainSet);


    // test data没有标注
    Pipe tpipe = featurePipe;
    // 测试集
    InstanceSet testSet = new InstanceSet(tpipe);

    testSet.loadThruPipes(new SequenceReader(testfile, false, "utf8"));
    System.out.println("测试样本个数: " + testSet.size()); //
    String[][] labelsSet = new String[testSet.size()][];
    for (int i = 0; i < testSet.size(); i++) {
      Instance carrier = testSet.get(i);
      int[] pred = (int[]) cl.classify(carrier).getLabel(0);
View Full Code Here

    LabelAlphabet labels = factory.DefaultLabelAlphabet();
    IFeatureAlphabet features = factory.DefaultFeatureAlphabet();

    // 训练集
    trainSet.loadThruStagePipes(new SequenceReader(train,true, "utf8"));

    long endTime = System.currentTimeMillis();
    System.out.println(" done!");
    System.out
    .println("Time escape: " + (endTime - beginTime) / 1000 + "s");
    System.out.println();

    // 输出
    System.out.println("Training Number: " + trainSet.size());

    System.out.println("Label Number: " + labels.size()); // 标签个数
    System.out.println("Feature Number: " + features.size()); // 特征个数

    // 冻结特征集
    features.setStopIncrement(true);
    labels.setStopIncrement(true);

    InstanceSet testSet = null;
    // /////////////////
    if (testfile != null) {

      Pipe tpipe;
      if (false) {// 如果test data没有标注
        tpipe = new SeriesPipes(new Pipe[] { featurePipe });
      } else {
        tpipe = pipe;
      }

      // 测试集
      testSet = new InstanceSet(tpipe);

      testSet.loadThruStagePipes(new SequenceReader(testfile, true, "utf8"));
      System.out.println("Test Number: " + testSet.size()); // 样本个数
    }

    /**
     *
 
View Full Code Here

    Pipe pipe = createProcessor(true);

    // 测试集
    InstanceSet testSet = new InstanceSet(pipe);

    testSet.loadThruStagePipes(new SequenceReader(testfile, true, "utf8"));
    System.out.println("Test Number: " + testSet.size()); // 样本个数

    long featuretime = System.currentTimeMillis();

    boolean acc = true;
View Full Code Here

    Pipe pipe = createProcessor(true);

    // 测试集
    InstanceSet testSet = new InstanceSet(pipe);

    testSet.loadThruStagePipes(new SequenceReader(testfile, true, "utf8"));
    System.out.println("Test Number: " + testSet.size()); // 样本个数

    long featuretime = System.currentTimeMillis();

    boolean acc = true;
View Full Code Here

TOP

Related Classes of org.fnlp.data.reader.SequenceReader

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.