Package opennlp.tools.util

Examples of opennlp.tools.util.TrainingParameters


        "opennlp/tools/namefind/OnlyWithEntitiesWithTypes.train");

    ObjectStream<NameSample> sampleStream = new NameSampleDataStream(
        new PlainTextByLineStream(new MockInputStreamFactory(in), "UTF-8"));

    TrainingParameters params = new TrainingParameters();
    params.put(TrainingParameters.ITERATIONS_PARAM, Integer.toString(70));
    params.put(TrainingParameters.CUTOFF_PARAM, Integer.toString(1));

    TokenNameFinderModel nameFinderModel = NameFinderME.train("en", TYPE, sampleStream,
        params, (byte[]) null, Collections.<String, Object>emptyMap());

    NameFinderME nameFinder = new NameFinderME(nameFinderModel);
View Full Code Here


        "opennlp/tools/namefind/voa1.train");

    ObjectStream<NameSample> sampleStream = new NameSampleDataStream(
       new PlainTextByLineStream(new MockInputStreamFactory(in), "UTF-8"));

    TrainingParameters params = new TrainingParameters();
    params.put(TrainingParameters.ITERATIONS_PARAM, Integer.toString(70));
    params.put(TrainingParameters.CUTOFF_PARAM, Integer.toString(1));

    TokenNameFinderModel nameFinderModel = NameFinderME.train("en", TYPE, sampleStream,
        params, (byte[]) null, Collections.<String, Object>emptyMap());

    NameFinderME nameFinder = new NameFinderME(nameFinderModel);
View Full Code Here

  private TrainingParameters mlParams;

  @Before
  public void setup() {
    mlParams = new TrainingParameters();
    mlParams.put(TrainingParameters.ALGORITHM_PARAM, GIS.MAXENT_VALUE);
    mlParams.put(TrainingParameters.ITERATIONS_PARAM, Integer.toString(10));
    mlParams.put(TrainingParameters.CUTOFF_PARAM, Integer.toString(5));
  }
View Full Code Here

    SentenceDetectorFactory sdFactory = SentenceDetectorFactory.create(
            null, language, true, null, eos);

  //  TrainingParameters mlParams = ModelUtil.createTrainingParameters(100, 5);
     TrainingParameters mlParams = ModelUtil.createDefaultTrainingParameters();
    ObjectStream<SentenceSample> samples = ObjectStreamUtils.createObjectStream(sentenceSamples);

    Writer samplesOut = null;

    if (sampleTraceFile != null) {
View Full Code Here

  }

  public static final TrainingParameters loadTrainingParams(String inFileValue,
      boolean isSequenceTrainingAllowed) throws ResourceInitializationException {

    TrainingParameters params;
    if (inFileValue != null) {
      InputStream paramsIn = null;
      try {
        paramsIn = new FileInputStream(new File(inFileValue));

        params = new opennlp.tools.util.TrainingParameters(paramsIn);
      } catch (IOException e) {
        throw new ResourceInitializationException(e);
      }
      finally {
        try {
          if (paramsIn != null)
            paramsIn.close();
        } catch (IOException e) {
        }
      }

      if (!TrainerFactory.isValid(params.getSettings())) {
        throw new ResourceInitializationException(new Exception("Training parameters file is invalid!"));
      }

      if (!isSequenceTrainingAllowed && TrainerFactory.isSequenceTraining(params.getSettings())) {
        throw new ResourceInitializationException(new Exception("Sequence training is not supported!"));
      }
    }
    else {
      params = TrainingParameters.defaultParams();
View Full Code Here

TOP

Related Classes of opennlp.tools.util.TrainingParameters

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.