Package opennlp.tools.tokenize

Examples of opennlp.tools.tokenize.TokenizerCrossValidator


    ObjectStream<TokenSample> sampleStream =
        TokenizerTrainerTool.openSampleData("Training Data",
        trainingDataInFile, encoding);
   
   
    TokenizerCrossValidator validator;
   
    if (mlParams == null)
      mlParams = TokenizerTrainerTool.createTrainingParameters(
          params.getIterations(), params.getCutoff());
   
    TokenizerEvaluationMonitor listener = null;
    if (params.getMisclassified()) {
      listener = new TokenEvaluationErrorListener();
    }
   
    try {
      Dictionary dict = TokenizerTrainerTool.loadDict(params.getAbbDict());

      validator = new opennlp.tools.tokenize.TokenizerCrossValidator(
          params.getLang(), dict, params.getAlphaNumOpt(), mlParams, listener);

      validator.evaluate(sampleStream, params.getFolds());
    }
    catch (IOException e) {
      CmdLineUtil.printTrainingIoError(e);
      throw new TerminateToolException(-1);
    }
    finally {
      try {
        sampleStream.close();
      } catch (IOException e) {
        // sorry that this can fail
      }
    }
   
    FMeasure result = validator.getFMeasure();
   
    System.out.println(result.toString());
  }
View Full Code Here


    mlParams = CmdLineUtil.loadTrainingParameters(params.getParams(), false);
    if (mlParams == null) {
      mlParams = ModelUtil.createTrainingParameters(params.getIterations(), params.getCutoff());
    }

    TokenizerCrossValidator validator;
   
    TokenizerEvaluationMonitor listener = null;
    if (params.getMisclassified()) {
      listener = new TokenEvaluationErrorListener();
    }
   
    try {
      Dictionary dict = TokenizerTrainerTool.loadDict(params.getAbbDict());

      TokenizerFactory tokFactory = TokenizerFactory.create(
          params.getFactory(), params.getLang(), dict,
          params.getAlphaNumOpt(), null);
      validator = new opennlp.tools.tokenize.TokenizerCrossValidator(mlParams,
          tokFactory, listener);

      validator.evaluate(sampleStream, params.getFolds());
    }
    catch (IOException e) {
      throw new TerminateToolException(-1, "IO error while reading training data or indexing data: "
          + e.getMessage(), e);
    }
    finally {
      try {
        sampleStream.close();
      } catch (IOException e) {
        // sorry that this can fail
      }
    }
   
    FMeasure result = validator.getFMeasure();
   
    System.out.println(result.toString());
  }
View Full Code Here

    mlParams = CmdLineUtil.loadTrainingParameters(params.getParams(), false);
    if (mlParams == null) {
      mlParams = ModelUtil.createDefaultTrainingParameters();
    }

    TokenizerCrossValidator validator;

    TokenizerEvaluationMonitor listener = null;
    if (params.getMisclassified()) {
      listener = new TokenEvaluationErrorListener();
    }

    try {
      Dictionary dict = TokenizerTrainerTool.loadDict(params.getAbbDict());

      TokenizerFactory tokFactory = TokenizerFactory.create(
          params.getFactory(), params.getLang(), dict,
          params.getAlphaNumOpt(), null);
      validator = new opennlp.tools.tokenize.TokenizerCrossValidator(mlParams,
          tokFactory, listener);

      validator.evaluate(sampleStream, params.getFolds());
    }
    catch (IOException e) {
      throw new TerminateToolException(-1, "IO error while reading training data or indexing data: "
          + e.getMessage(), e);
    }
    finally {
      try {
        sampleStream.close();
      } catch (IOException e) {
        // sorry that this can fail
      }
    }

    FMeasure result = validator.getFMeasure();

    System.out.println(result.toString());
  }
View Full Code Here

   
    ObjectStream<TokenSample> sampleStream =
        TokenizerTrainerTool.openSampleData("Training Data",
        trainingDataInFile, parameters.getEncoding());
   
    TokenizerCrossValidator validator =
        new opennlp.tools.tokenize.TokenizerCrossValidator(
        parameters.getLanguage(), parameters.isAlphaNumericOptimizationEnabled());
     
    try {
      validator.evaluate(sampleStream, 10);
    }
    catch (IOException e) {
      CmdLineUtil.printTrainingIoError(e);
      throw new TerminateToolException(-1);
    }
    finally {
      try {
        sampleStream.close();
      } catch (IOException e) {
        // sorry that this can fail
      }
    }
   
    FMeasure result = validator.getFMeasure();
   
    System.out.println(result.toString());
  }
View Full Code Here

TOP

Related Classes of opennlp.tools.tokenize.TokenizerCrossValidator

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.