Package opennlp.model

Examples of opennlp.model.DataIndexer


public class QNTrainerTest {
  @Test
  public void testTrainModelReturnsAQNModel() throws Exception {
    // given
    RealValueFileEventStream rvfes1 = new RealValueFileEventStream("src/test/resources/data/opennlp/maxent/real-valued-weights-training-data.txt")
    DataIndexer testDataIndexer = new OnePassRealValueDataIndexer(rvfes1,1);
    // when
    QNModel trainedModel = new QNTrainer(false).trainModel(testDataIndexer);
    // then
    assertNotNull(trainedModel);
  }
View Full Code Here


  @Test
  public void testInTinyDevSet() throws Exception {
    // given
    RealValueFileEventStream rvfes1 = new RealValueFileEventStream("src/test/resources/data/opennlp/maxent/real-valued-weights-training-data.txt")
    DataIndexer testDataIndexer = new OnePassRealValueDataIndexer(rvfes1,1);
    // when
    QNModel trainedModel = new QNTrainer(15, true).trainModel(testDataIndexer);
    String[] features2Classify = new String[] {"feature2","feature3", "feature3", "feature3","feature3", "feature3", "feature3","feature3", "feature3", "feature3","feature3", "feature3"};
    double[] eval = trainedModel.eval(features2Classify);
    // then
View Full Code Here

 
  @Test
  public void testModel() throws IOException {
      // given
      RealValueFileEventStream rvfes1 = new RealValueFileEventStream("src/test/resources/data/opennlp/maxent/real-valued-weights-training-data.txt")
      DataIndexer testDataIndexer = new OnePassRealValueDataIndexer(rvfes1,1);
      // when
      QNModel trainedModel = new QNTrainer(15, true).trainModel(testDataIndexer);
     
      assertTrue(trainedModel.equals(trainedModel))
      assertFalse(trainedModel.equals(null));
View Full Code Here

 
  @Test
  public void testSerdeModel() throws IOException {
      // given
      RealValueFileEventStream rvfes1 = new RealValueFileEventStream("src/test/resources/data/opennlp/maxent/real-valued-weights-training-data.txt")
      DataIndexer testDataIndexer = new OnePassRealValueDataIndexer(rvfes1,1);
      // when
     // QNModel trainedModel = new QNTrainer(5, 500, true).trainModel(new TwoPassDataIndexer(createTrainingStream()));
      QNModel trainedModel = new QNTrainer(5, 700, true).trainModel(testDataIndexer);
     
      ByteArrayOutputStream modelBytes = new ByteArrayOutputStream();
View Full Code Here

  int numSequences;

  public AbstractModel trainModel(int iterations, SequenceStream sequenceStream, int cutoff, boolean useAverage) throws IOException {
    this.iterations = iterations;
    this.sequenceStream = sequenceStream;
    DataIndexer di = new OnePassDataIndexer(new SequenceStreamEventStream(sequenceStream),cutoff,false);
    numSequences = 0;
    for (Sequence s : sequenceStream) {
      numSequences++;
    }
    outcomeList  = di.getOutcomeList();
    predLabels = di.getPredLabels();
    pmap = new HashMap<String,Integer>();
    for (int pli=0;pli<predLabels.length;pli++) {
      pmap.put(predLabels[pli], pli);
    }
    display("Incorporating indexed data for training...  \n");
    this.useAverage = useAverage;
    numEvents = di.getNumEvents();

    this.iterations = iterations;
    outcomeLabels = di.getOutcomeLabels();
    omap = new HashMap<String,Integer>();
    for (int oli=0;oli<outcomeLabels.length;oli++) {
      omap.put(outcomeLabels[oli], oli);
    }
    outcomeList = di.getOutcomeList();

    numPreds = predLabels.length;
    numOutcomes = outcomeLabels.length;
    if (useAverage) {
      updates = new int[numPreds][numOutcomes][3];
View Full Code Here

TOP

Related Classes of opennlp.model.DataIndexer

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.