You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opennlp.apache.org by jo...@apache.org on 2017/04/20 10:41:22 UTC

[35/50] [abbrv] opennlp git commit: OPENNLP-1002 Remove deprecated GIS class

OPENNLP-1002 Remove deprecated GIS class


Project: http://git-wip-us.apache.org/repos/asf/opennlp/repo
Commit: http://git-wip-us.apache.org/repos/asf/opennlp/commit/91c4baae
Tree: http://git-wip-us.apache.org/repos/asf/opennlp/tree/91c4baae
Diff: http://git-wip-us.apache.org/repos/asf/opennlp/diff/91c4baae

Branch: refs/heads/parser_regression
Commit: 91c4baaecfae3c88d30ea14a04dafa63dab191e7
Parents: 6b910d5
Author: J�rn Kottmann <jo...@apache.org>
Authored: Sun Mar 12 11:10:43 2017 +0100
Committer: J�rn Kottmann <jo...@apache.org>
Committed: Thu Apr 20 12:40:23 2017 +0200

----------------------------------------------------------------------
 .../cmdline/parser/BuildModelUpdaterTool.java   |   7 +-
 .../cmdline/parser/CheckModelUpdaterTool.java   |   7 +-
 .../main/java/opennlp/tools/ml/maxent/GIS.java  | 303 -------------------
 .../tools/ml/maxent/GISIndexingTest.java        |  78 +++--
 .../tools/ml/maxent/ScaleDoesntMatterTest.java  |  20 +-
 5 files changed, 80 insertions(+), 335 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/opennlp/blob/91c4baae/opennlp-tools/src/main/java/opennlp/tools/cmdline/parser/BuildModelUpdaterTool.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/cmdline/parser/BuildModelUpdaterTool.java b/opennlp-tools/src/main/java/opennlp/tools/cmdline/parser/BuildModelUpdaterTool.java
index 327355b..7efd342 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/cmdline/parser/BuildModelUpdaterTool.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/cmdline/parser/BuildModelUpdaterTool.java
@@ -20,7 +20,8 @@ package opennlp.tools.cmdline.parser;
 import java.io.IOException;
 
 import opennlp.tools.dictionary.Dictionary;
-import opennlp.tools.ml.maxent.GIS;
+import opennlp.tools.ml.EventTrainer;
+import opennlp.tools.ml.TrainerFactory;
 import opennlp.tools.ml.model.Event;
 import opennlp.tools.ml.model.MaxentModel;
 import opennlp.tools.parser.Parse;
@@ -28,6 +29,7 @@ import opennlp.tools.parser.ParserEventTypeEnum;
 import opennlp.tools.parser.ParserModel;
 import opennlp.tools.parser.chunking.ParserEventStream;
 import opennlp.tools.util.ObjectStream;
+import opennlp.tools.util.model.ModelUtil;
 
 public final class BuildModelUpdaterTool extends ModelUpdaterTool {
 
@@ -50,7 +52,8 @@ public final class BuildModelUpdaterTool extends ModelUpdaterTool {
     ObjectStream<Event> bes = new ParserEventStream(parseSamples,
         originalModel.getHeadRules(), ParserEventTypeEnum.BUILD, mdict);
 
-    GIS trainer = new GIS();
+    EventTrainer trainer = TrainerFactory.getEventTrainer(
+        ModelUtil.createDefaultTrainingParameters(), null);
     MaxentModel buildModel = trainer.train(bes);
 
     parseSamples.close();

http://git-wip-us.apache.org/repos/asf/opennlp/blob/91c4baae/opennlp-tools/src/main/java/opennlp/tools/cmdline/parser/CheckModelUpdaterTool.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/cmdline/parser/CheckModelUpdaterTool.java b/opennlp-tools/src/main/java/opennlp/tools/cmdline/parser/CheckModelUpdaterTool.java
index 55e96ba..0c98812 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/cmdline/parser/CheckModelUpdaterTool.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/cmdline/parser/CheckModelUpdaterTool.java
@@ -20,7 +20,8 @@ package opennlp.tools.cmdline.parser;
 import java.io.IOException;
 
 import opennlp.tools.dictionary.Dictionary;
-import opennlp.tools.ml.maxent.GIS;
+import opennlp.tools.ml.EventTrainer;
+import opennlp.tools.ml.TrainerFactory;
 import opennlp.tools.ml.model.Event;
 import opennlp.tools.ml.model.MaxentModel;
 import opennlp.tools.parser.Parse;
@@ -28,6 +29,7 @@ import opennlp.tools.parser.ParserEventTypeEnum;
 import opennlp.tools.parser.ParserModel;
 import opennlp.tools.parser.chunking.ParserEventStream;
 import opennlp.tools.util.ObjectStream;
+import opennlp.tools.util.model.ModelUtil;
 
 // trains a new check model ...
 public final class CheckModelUpdaterTool extends ModelUpdaterTool {
@@ -51,7 +53,8 @@ public final class CheckModelUpdaterTool extends ModelUpdaterTool {
     ObjectStream<Event> bes = new ParserEventStream(parseSamples,
         originalModel.getHeadRules(), ParserEventTypeEnum.CHECK, mdict);
 
-    GIS trainer = new GIS();
+    EventTrainer trainer = TrainerFactory.getEventTrainer(
+        ModelUtil.createDefaultTrainingParameters(), null);
     MaxentModel checkModel = trainer.train(bes);
 
     parseSamples.close();

http://git-wip-us.apache.org/repos/asf/opennlp/blob/91c4baae/opennlp-tools/src/main/java/opennlp/tools/ml/maxent/GIS.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/ml/maxent/GIS.java b/opennlp-tools/src/main/java/opennlp/tools/ml/maxent/GIS.java
deleted file mode 100644
index 97c214d..0000000
--- a/opennlp-tools/src/main/java/opennlp/tools/ml/maxent/GIS.java
+++ /dev/null
@@ -1,303 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package opennlp.tools.ml.maxent;
-
-import java.io.IOException;
-
-import opennlp.tools.ml.AbstractEventTrainer;
-import opennlp.tools.ml.model.AbstractModel;
-import opennlp.tools.ml.model.DataIndexer;
-import opennlp.tools.ml.model.Event;
-import opennlp.tools.ml.model.Prior;
-import opennlp.tools.ml.model.UniformPrior;
-import opennlp.tools.util.ObjectStream;
-import opennlp.tools.util.TrainingParameters;
-
-/**
- * A Factory class which uses instances of GISTrainer to create and train
- * GISModels.
- * @deprecated use {@link GISTrainer}
- */
-@Deprecated
-public class GIS extends AbstractEventTrainer {
-
-  public static final String MAXENT_VALUE = "MAXENT";
-
-  /**
-   * Set this to false if you don't want messages about the progress of model
-   * training displayed. Alternately, you can use the overloaded version of
-   * trainModel() to conditionally enable progress messages.
-   */
-  public static boolean PRINT_MESSAGES = true;
-
-  /**
-   * If we are using smoothing, this is used as the "number" of times we want
-   * the trainer to imagine that it saw a feature that it actually didn't see.
-   * Defaulted to 0.1.
-   */
-  private static final double SMOOTHING_OBSERVATION = 0.1;
-
-  private static final String SMOOTHING_PARAM = "smoothing";
-  private static final boolean SMOOTHING_DEFAULT = false;
-
-  public GIS() {
-  }
-
-  public GIS(TrainingParameters parameters) {
-    super(parameters);
-  }
-  
-  public boolean isValid() {
-
-    if (!super.isValid()) {
-      return false;
-    }
-
-    String algorithmName = getAlgorithm();
-
-    return !(algorithmName != null && !(MAXENT_VALUE.equals(algorithmName)));
-  }
-
-  public boolean isSortAndMerge() {
-    return true;
-  }
-
-  public AbstractModel doTrain(DataIndexer indexer) throws IOException {
-    int iterations = getIterations();
-
-    AbstractModel model;
-
-    boolean printMessages = trainingParameters.getBooleanParameter(VERBOSE_PARAM, VERBOSE_DEFAULT);
-    boolean smoothing = trainingParameters.getBooleanParameter(SMOOTHING_PARAM, SMOOTHING_DEFAULT);
-    int threads = trainingParameters.getIntParameter(TrainingParameters.THREADS_PARAM, 1);
-
-    model = trainModel(iterations, indexer, printMessages, smoothing, null, threads);
-
-    return model;
-  }
-
-  // << members related to AbstractEventTrainer
-
-  /**
-   * Train a model using the GIS algorithm, assuming 100 iterations and no
-   * cutoff.
-   *
-   * @param eventStream
-   *          The EventStream holding the data on which this model will be
-   *          trained.
-   * @return The newly trained model, which can be used immediately or saved to
-   *         disk using an opennlp.tools.ml.maxent.io.GISModelWriter object.
-   */
-  public static GISModel trainModel(ObjectStream<Event> eventStream) throws IOException {
-    return trainModel(eventStream, 100, 0, false, PRINT_MESSAGES);
-  }
-
-  /**
-   * Train a model using the GIS algorithm, assuming 100 iterations and no
-   * cutoff.
-   *
-   * @param eventStream
-   *          The EventStream holding the data on which this model will be
-   *          trained.
-   * @param smoothing
-   *          Defines whether the created trainer will use smoothing while
-   *          training the model.
-   * @return The newly trained model, which can be used immediately or saved to
-   *         disk using an opennlp.tools.ml.maxent.io.GISModelWriter object.
-   */
-  public static GISModel trainModel(ObjectStream<Event> eventStream, boolean smoothing)
-      throws IOException {
-    return trainModel(eventStream, 100, 0, smoothing, PRINT_MESSAGES);
-  }
-
-  /**
-   * Train a model using the GIS algorithm.
-   *
-   * @param eventStream
-   *          The EventStream holding the data on which this model will be
-   *          trained.
-   * @param iterations
-   *          The number of GIS iterations to perform.
-   * @param cutoff
-   *          The number of times a feature must be seen in order to be relevant
-   *          for training.
-   * @return The newly trained model, which can be used immediately or saved to
-   *         disk using an opennlp.tools.ml.maxent.io.GISModelWriter object.
-   */
-  public static GISModel trainModel(ObjectStream<Event> eventStream, int iterations,
-      int cutoff) throws IOException {
-    return trainModel(eventStream, iterations, cutoff, false, PRINT_MESSAGES);
-  }
-
-  /**
-   * Train a model using the GIS algorithm.
-   *
-   * @param eventStream
-   *          The EventStream holding the data on which this model will be
-   *          trained.
-   * @param iterations
-   *          The number of GIS iterations to perform.
-   * @param cutoff
-   *          The number of times a feature must be seen in order to be relevant
-   *          for training.
-   * @param smoothing
-   *          Defines whether the created trainer will use smoothing while
-   *          training the model.
-   * @param printMessagesWhileTraining
-   *          Determines whether training status messages are written to STDOUT.
-   * @return The newly trained model, which can be used immediately or saved to
-   *         disk using an opennlp.tools.ml.maxent.io.GISModelWriter object.
-   */
-  public static GISModel trainModel(ObjectStream<Event> eventStream, int iterations,
-      int cutoff, boolean smoothing, boolean printMessagesWhileTraining)
-      throws IOException {
-    GISTrainer trainer = new GISTrainer(printMessagesWhileTraining);
-    trainer.setSmoothing(smoothing);
-    trainer.setSmoothingObservation(SMOOTHING_OBSERVATION);
-    return trainer.trainModel(eventStream, iterations, cutoff);
-  }
-
-  /**
-   * Train a model using the GIS algorithm.
-   *
-   * @param eventStream
-   *          The EventStream holding the data on which this model will be
-   *          trained.
-   * @param iterations
-   *          The number of GIS iterations to perform.
-   * @param cutoff
-   *          The number of times a feature must be seen in order to be relevant
-   *          for training.
-   * @param sigma
-   *          The standard deviation for the gaussian smoother.
-   * @return The newly trained model, which can be used immediately or saved to
-   *         disk using an opennlp.tools.ml.maxent.io.GISModelWriter object.
-   */
-  public static GISModel trainModel(ObjectStream<Event> eventStream, int iterations,
-      int cutoff, double sigma) throws IOException {
-    GISTrainer trainer = new GISTrainer(PRINT_MESSAGES);
-    if (sigma > 0) {
-      trainer.setGaussianSigma(sigma);
-    }
-    return trainer.trainModel(eventStream, iterations, cutoff);
-  }
-
-  /**
-   * Train a model using the GIS algorithm.
-   *
-   * @param iterations
-   *          The number of GIS iterations to perform.
-   * @param indexer
-   *          The object which will be used for event compilation.
-   * @param smoothing
-   *          Defines whether the created trainer will use smoothing while
-   *          training the model.
-   * @return The newly trained model, which can be used immediately or saved to
-   *         disk using an opennlp.tools.ml.maxent.io.GISModelWriter object.
-   */
-  public static GISModel trainModel(int iterations, DataIndexer indexer, boolean smoothing) {
-    return trainModel(iterations, indexer, true, smoothing, null, 1);
-  }
-
-  /**
-   * Train a model using the GIS algorithm.
-   *
-   * @param iterations
-   *          The number of GIS iterations to perform.
-   * @param indexer
-   *          The object which will be used for event compilation.
-   * @return The newly trained model, which can be used immediately or saved to
-   *         disk using an opennlp.tools.ml.maxent.io.GISModelWriter object.
-   */
-  public static GISModel trainModel(int iterations, DataIndexer indexer) {
-    return trainModel(iterations, indexer, true, false, null, 1);
-  }
-
-  /**
-   * Train a model using the GIS algorithm with the specified number of
-   * iterations, data indexer, and prior.
-   *
-   * @param iterations
-   *          The number of GIS iterations to perform.
-   * @param indexer
-   *          The object which will be used for event compilation.
-   * @param modelPrior
-   *          The prior distribution for the model.
-   * @return The newly trained model, which can be used immediately or saved to
-   *         disk using an opennlp.tools.ml.maxent.io.GISModelWriter object.
-   */
-  public static GISModel trainModel(int iterations, DataIndexer indexer,
-      Prior modelPrior, int cutoff) {
-    return trainModel(iterations, indexer, true, false, modelPrior, cutoff);
-  }
-
-  /**
-   * Train a model using the GIS algorithm.
-   *
-   * @param iterations
-   *          The number of GIS iterations to perform.
-   * @param indexer
-   *          The object which will be used for event compilation.
-   * @param printMessagesWhileTraining
-   *          Determines whether training status messages are written to STDOUT.
-   * @param smoothing
-   *          Defines whether the created trainer will use smoothing while
-   *          training the model.
-   * @param modelPrior
-   *          The prior distribution for the model.
-   * @return The newly trained model, which can be used immediately or saved to
-   *         disk using an opennlp.tools.ml.maxent.io.GISModelWriter object.
-   */
-  public static GISModel trainModel(int iterations, DataIndexer indexer,
-                                    boolean printMessagesWhileTraining, boolean smoothing,
-                                    Prior modelPrior) {
-    return trainModel(iterations, indexer, printMessagesWhileTraining, smoothing, modelPrior, 1);
-  }
-
-  /**
-   * Train a model using the GIS algorithm.
-   *
-   * @param iterations
-   *          The number of GIS iterations to perform.
-   * @param indexer
-   *          The object which will be used for event compilation.
-   * @param printMessagesWhileTraining
-   *          Determines whether training status messages are written to STDOUT.
-   * @param smoothing
-   *          Defines whether the created trainer will use smoothing while
-   *          training the model.
-   * @param modelPrior
-   *          The prior distribution for the model.
-   * @return The newly trained model, which can be used immediately or saved to
-   *         disk using an opennlp.tools.ml.maxent.io.GISModelWriter object.
-   */
-  public static GISModel trainModel(int iterations, DataIndexer indexer,
-                                    boolean printMessagesWhileTraining, boolean smoothing,
-                                    Prior modelPrior, int threads) {
-    GISTrainer trainer = new GISTrainer(printMessagesWhileTraining);
-    trainer.setSmoothing(smoothing);
-    trainer.setSmoothingObservation(SMOOTHING_OBSERVATION);
-    if (modelPrior == null) {
-      modelPrior = new UniformPrior();
-    }
-    return trainer.trainModel(iterations, indexer, modelPrior, threads);
-  }
-}
-
-
-

http://git-wip-us.apache.org/repos/asf/opennlp/blob/91c4baae/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/GISIndexingTest.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/GISIndexingTest.java b/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/GISIndexingTest.java
index 6922603..c8bc27f 100644
--- a/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/GISIndexingTest.java
+++ b/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/GISIndexingTest.java
@@ -17,6 +17,7 @@
 
 package opennlp.tools.ml.maxent;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -26,6 +27,7 @@ import org.junit.Assert;
 import org.junit.Test;
 
 import opennlp.tools.ml.AbstractEventTrainer;
+import opennlp.tools.ml.AbstractTrainer;
 import opennlp.tools.ml.EventTrainer;
 import opennlp.tools.ml.TrainerFactory;
 import opennlp.tools.ml.maxent.quasinewton.QNTrainer;
@@ -36,6 +38,7 @@ import opennlp.tools.ml.model.Event;
 import opennlp.tools.util.ObjectStream;
 import opennlp.tools.util.ObjectStreamUtils;
 import opennlp.tools.util.TrainingParameters;
+import opennlp.tools.util.model.ModelUtil;
 
 public class GISIndexingTest {
 
@@ -58,40 +61,63 @@ public class GISIndexingTest {
    * Test the GIS.trainModel(ObjectStream<Event> eventStream) method
    */
   @Test
-  public void testGISTrainSignature1() throws Exception {
-    ObjectStream<Event> eventStream = createEventStream();
-    Assert.assertNotNull(GIS.trainModel(eventStream));
-    eventStream.close();
+  public void testGISTrainSignature1() throws IOException {
+    try (ObjectStream<Event> eventStream = createEventStream()) {
+      TrainingParameters params = ModelUtil.createDefaultTrainingParameters();
+      params.put(AbstractTrainer.CUTOFF_PARAM, "1");
+
+      EventTrainer trainer = TrainerFactory.getEventTrainer(params,  null);
+
+      Assert.assertNotNull(trainer.train(eventStream));
+    }
   }
 
   /*
    * Test the GIS.trainModel(ObjectStream<Event> eventStream,boolean smoothing) method
    */
   @Test
-  public void testGISTrainSignature2() throws Exception {
-    ObjectStream<Event> eventStream = createEventStream();
-    Assert.assertNotNull(GIS.trainModel(eventStream,true));
-    eventStream.close();
+  public void testGISTrainSignature2() throws IOException {
+    try (ObjectStream<Event> eventStream = createEventStream()) {
+      TrainingParameters params = ModelUtil.createDefaultTrainingParameters();
+      params.put(AbstractTrainer.CUTOFF_PARAM, "1");
+      params.put("smoothing", "true");
+      EventTrainer trainer = TrainerFactory.getEventTrainer(params, null);
+
+      Assert.assertNotNull(trainer.train(eventStream));
+    }
   }
   
   /*
    * Test the GIS.trainModel(ObjectStream<Event> eventStream, int iterations, int cutoff) method
    */
   @Test
-  public void testGISTrainSignature3() throws Exception {
-    ObjectStream<Event> eventStream = createEventStream();
-    Assert.assertNotNull(GIS.trainModel(eventStream,10,1));
-    eventStream.close();
+  public void testGISTrainSignature3() throws IOException {
+    try (ObjectStream<Event> eventStream = createEventStream()) {
+      TrainingParameters params = ModelUtil.createDefaultTrainingParameters();
+
+      params.put(AbstractTrainer.ITERATIONS_PARAM, "10");
+      params.put(AbstractTrainer.CUTOFF_PARAM, "1");
+
+      EventTrainer trainer = TrainerFactory.getEventTrainer(params, null);
+
+      Assert.assertNotNull(trainer.train(eventStream));
+    }
   }
  
   /*
    * Test the GIS.trainModel(ObjectStream<Event> eventStream, int iterations, int cutoff, double sigma) method
    */
   @Test
-  public void testGISTrainSignature4() throws Exception {
-    ObjectStream<Event> eventStream = createEventStream();
-    Assert.assertNotNull(GIS.trainModel(eventStream,10,1,0.01));
-    eventStream.close();
+  public void testGISTrainSignature4() throws IOException {
+    try (ObjectStream<Event> eventStream = createEventStream()) {
+      TrainingParameters params = ModelUtil.createDefaultTrainingParameters();
+      params.put(AbstractTrainer.ITERATIONS_PARAM, "10");
+      params.put(AbstractTrainer.CUTOFF_PARAM, "1");
+      GISTrainer trainer = (GISTrainer) TrainerFactory.getEventTrainer(params, null);
+      trainer.setGaussianSigma(0.01);
+
+      Assert.assertNotNull(trainer.trainModel(eventStream));
+    }
   }
   
   /*
@@ -99,14 +125,22 @@ public class GISIndexingTest {
    * boolean smoothing, boolean printMessagesWhileTraining)) method
    */
   @Test
-  public void testGISTrainSignature5() throws Exception {
-    ObjectStream<Event> eventStream = createEventStream();
-    Assert.assertNotNull(GIS.trainModel(eventStream,10,1,false,false));
-    eventStream.close();
+  public void testGISTrainSignature5() throws IOException {
+    try (ObjectStream<Event> eventStream = createEventStream()) {
+      TrainingParameters params = ModelUtil.createDefaultTrainingParameters();
+
+      params.put(AbstractTrainer.ITERATIONS_PARAM, "10");
+      params.put(AbstractTrainer.CUTOFF_PARAM, "1");
+      params.put("smoothing", "false");
+      params.put(AbstractTrainer.VERBOSE_PARAM, "false");
+
+      EventTrainer trainer = TrainerFactory.getEventTrainer(params, null);
+      Assert.assertNotNull(trainer.train(eventStream));
+    }
   }
   
   @Test
-  public void testIndexingWithTrainingParameters() throws Exception {
+  public void testIndexingWithTrainingParameters() throws IOException {
     ObjectStream<Event> eventStream = createEventStream();
     
     TrainingParameters parameters = TrainingParameters.defaultParams();
@@ -147,7 +181,7 @@ public class GISIndexingTest {
   }
   
   @Test
-  public void testIndexingFactory() throws Exception {
+  public void testIndexingFactory() throws IOException {
     Map<String,String> myReportMap = new HashMap<>();
     ObjectStream<Event> eventStream = createEventStream();
 

http://git-wip-us.apache.org/repos/asf/opennlp/blob/91c4baae/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/ScaleDoesntMatterTest.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/ScaleDoesntMatterTest.java b/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/ScaleDoesntMatterTest.java
index 76a4813..1e5c8a3 100644
--- a/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/ScaleDoesntMatterTest.java
+++ b/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/ScaleDoesntMatterTest.java
@@ -25,6 +25,8 @@ import org.junit.Before;
 import org.junit.Test;
 
 import opennlp.tools.ml.AbstractTrainer;
+import opennlp.tools.ml.EventTrainer;
+import opennlp.tools.ml.TrainerFactory;
 import opennlp.tools.ml.model.DataIndexer;
 import opennlp.tools.ml.model.Event;
 import opennlp.tools.ml.model.MaxentModel;
@@ -34,6 +36,7 @@ import opennlp.tools.util.MockInputStreamFactory;
 import opennlp.tools.util.ObjectStream;
 import opennlp.tools.util.PlainTextByLineStream;
 import opennlp.tools.util.TrainingParameters;
+import opennlp.tools.util.model.ModelUtil;
 
 public class ScaleDoesntMatterTest {
 
@@ -52,7 +55,6 @@ public class ScaleDoesntMatterTest {
    * predicates doesn't matter when it comes the probability assigned to each
    * outcome. Strangely, if we use (1,2) and (10,20) there's no difference. If
    * we use (0.1,0.2) and (10,20) there is a difference.
-   *
    */
   @Test
   public void testScaleResults() throws Exception {
@@ -68,8 +70,11 @@ public class ScaleDoesntMatterTest {
         new PlainTextByLineStream(new MockInputStreamFactory(smallValues), StandardCharsets.UTF_8));
 
     testDataIndexer.index(smallEventStream);
-    MaxentModel smallModel = GIS.trainModel(100,
-        testDataIndexer, false);
+
+    EventTrainer smallModelTrainer = TrainerFactory.getEventTrainer(
+        ModelUtil.createDefaultTrainingParameters(), null);
+
+    MaxentModel smallModel = smallModelTrainer.train(testDataIndexer);
     String[] contexts = smallTest.split(" ");
     float[] values = RealValueFileEventStream.parseContexts(contexts);
     double[] smallResults = smallModel.eval(contexts, values);
@@ -81,13 +86,16 @@ public class ScaleDoesntMatterTest {
         new PlainTextByLineStream(new MockInputStreamFactory(largeValues), StandardCharsets.UTF_8));
 
     testDataIndexer.index(largeEventStream);
-    MaxentModel largeModel = GIS.trainModel(100,
-        testDataIndexer, false);
+
+    EventTrainer largeModelTrainer = TrainerFactory.getEventTrainer(
+        ModelUtil.createDefaultTrainingParameters(), null);
+
+    MaxentModel largeModel = largeModelTrainer.train(testDataIndexer);
     contexts = largeTest.split(" ");
     values = RealValueFileEventStream.parseContexts(contexts);
     double[] largeResults = largeModel.eval(contexts, values);
 
-    String largeResultString = smallModel.getAllOutcomes(largeResults);
+    String largeResultString = largeModel.getAllOutcomes(largeResults);
     System.out.println("largeResults: " + largeResultString);
 
     Assert.assertEquals(smallResults.length, largeResults.length);