Package opennlp.tools.ml.model

Examples of opennlp.tools.ml.model.DataIndexer


    String dataIndexerName = getStringParam(DATA_INDEXER_PARAM,
        DATA_INDEXER_TWO_PASS_VALUE);

    int cutoff = getCutoff();
    boolean sortAndMerge = isSortAndMerge();
    DataIndexer indexer = null;

    if (DATA_INDEXER_ONE_PASS_VALUE.equals(dataIndexerName)) {
      indexer = new OnePassDataIndexer(events, cutoff, sortAndMerge);
    } else if (DATA_INDEXER_TWO_PASS_VALUE.equals(dataIndexerName)) {
      indexer = new TwoPassDataIndexer(events, cutoff, sortAndMerge);
View Full Code Here


    if (!isValid()) {
      throw new IllegalArgumentException("trainParams are not valid!");
    }

    HashSumEventStream hses = new HashSumEventStream(events);
    DataIndexer indexer = getDataIndexer(events);

    MaxentModel model = doTrain(indexer);

    addToReport("Training-Eventhash", hses.calculateHashSum().toString(16));
    addToReport(AbstractTrainer.TRAINER_TYPE_PARAM, EventTrainer.EVENT_VALUE);
View Full Code Here

  // << members related to AbstractSequenceTrainer

  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;

    sequenceStream.reset();

    while (sequenceStream.read() != null) {
      numSequences++;
    }

    outcomeList  = di.getOutcomeList();
    predLabels = di.getPredLabels();
    pmap = new IndexHashTable<String>(predLabels, 0.7d);

    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

  @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(ITERATIONS, 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(ITERATIONS, testDataIndexer);
    String[] features2Classify = new String[] {
        "feature2","feature3", "feature3",
        "feature3","feature3", "feature3",
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(
          ITERATIONS, testDataIndexer);
     
      assertTrue(trainedModel.equals(trainedModel))
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, 700, true).trainModel(ITERATIONS, testDataIndexer);
     
      ByteArrayOutputStream modelBytes = new ByteArrayOutputStream();
      GenericModelWriter modelWriter = new GenericModelWriter(trainedModel,
View Full Code Here

  @Test
  public void testDomainDimensionSanity() throws IOException {
    // given
    RealValueFileEventStream rvfes1 = new RealValueFileEventStream(
        "src/test/resources/data/opennlp/maxent/real-valued-weights-training-data.txt", "UTF-8")
    DataIndexer testDataIndexer = new OnePassRealValueDataIndexer(rvfes1,1);
    NegLogLikelihood objectFunction = new NegLogLikelihood(testDataIndexer);
    // when
    int correctDomainDimension = testDataIndexer.getPredLabels().length
        * testDataIndexer.getOutcomeLabels().length;
    // then
    assertEquals(correctDomainDimension, objectFunction.getDimension());
  }
View Full Code Here

  @Test
  public void testInitialSanity() throws IOException {
    // given
    RealValueFileEventStream rvfes1 = new RealValueFileEventStream(
        "src/test/resources/data/opennlp/maxent/real-valued-weights-training-data.txt", "UTF-8")
    DataIndexer testDataIndexer = new OnePassRealValueDataIndexer(rvfes1,1);
    NegLogLikelihood objectFunction = new NegLogLikelihood(testDataIndexer);
    // when
    double[] initial = objectFunction.getInitialPoint();
    // then
    for (int i = 0; i < initial.length; i++) {
View Full Code Here

  @Test
  public void testGradientSanity() throws IOException {
    // given
    RealValueFileEventStream rvfes1 = new RealValueFileEventStream(
        "src/test/resources/data/opennlp/maxent/real-valued-weights-training-data.txt", "UTF-8")
    DataIndexer testDataIndexer = new OnePassRealValueDataIndexer(rvfes1,1);
    NegLogLikelihood objectFunction = new NegLogLikelihood(testDataIndexer);
    // when
    double[] initial = objectFunction.getInitialPoint();
    double[] gradientAtInitial = objectFunction.gradientAt(initial);
    // then
View Full Code Here

TOP

Related Classes of opennlp.tools.ml.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.