Package opennlp.tools.tokenize

Examples of opennlp.tools.tokenize.TokenizerEvaluator


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

    TokenizerEvaluator evaluator = new TokenizerEvaluator(
        new opennlp.tools.tokenize.TokenizerME(model), missclassifiedListener);

    System.out.print("Evaluating ... ");
   
    File testData = params.getData();
    CmdLineUtil.checkInputFile("Test data", testData);

    ObjectStream<TokenSample> sampleStream = TokenizerTrainerTool
        .openSampleData("Test", testData, encoding);

    try {
      evaluator.evaluate(sampleStream);
    } catch (IOException e) {
      System.err.println("failed");
      System.err.println("Reading test data error " + e.getMessage());
      throw new TerminateToolException(-1);
    } finally {
      try {
        sampleStream.close();
      } catch (IOException e) {
        // sorry that this can fail
      }
    }
   
    System.out.println("done");

    System.out.println();

    System.out.println(evaluator.getFMeasure());
  }
View Full Code Here


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

    TokenizerEvaluator evaluator = new TokenizerEvaluator(
        new opennlp.tools.tokenize.TokenizerME(model), misclassifiedListener);

    System.out.print("Evaluating ... ");

    try {
      evaluator.evaluate(sampleStream);
    } catch (IOException e) {
      System.err.println("failed");
      throw new TerminateToolException(-1, "IO error while reading test data: " + e.getMessage(), e);
    } finally {
      try {
        sampleStream.close();
      } catch (IOException e) {
        // sorry that this can fail
      }
    }
   
    System.out.println("done");

    System.out.println();

    System.out.println(evaluator.getFMeasure());
  }
View Full Code Here

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

    TokenizerEvaluator evaluator = new TokenizerEvaluator(
        new opennlp.tools.tokenize.TokenizerME(model), misclassifiedListener);

    System.out.print("Evaluating ... ");

    try {
      evaluator.evaluate(sampleStream);
    } catch (IOException e) {
      System.err.println("failed");
      throw new TerminateToolException(-1, "IO error while reading test data: " + e.getMessage(), e);
    } finally {
      try {
        sampleStream.close();
      } catch (IOException e) {
        // sorry that this can fail
      }
    }

    System.out.println("done");

    System.out.println();

    System.out.println(evaluator.getFMeasure());
  }
View Full Code Here

    }

    TokenizerModel model = new TokenizerModelLoader().load(
        new File(CmdLineUtil.getParameter("-model", args)));

    TokenizerEvaluator evaluator = new TokenizerEvaluator(
        new opennlp.tools.tokenize.TokenizerME(model));

    System.out.print("Evaluating ... ");

    ObjectStream<TokenSample> sampleStream = TokenizerTrainerTool.openSampleData(
        "Test", new File(CmdLineUtil.getParameter("-data", args)), encoding);

    try {
      evaluator.evaluate(sampleStream);
    } catch (IOException e) {
      System.err.println("failed");
      System.err.println("Reading test data error " + e.getMessage());
      throw new TerminateToolException(-1);
    } finally {
      try {
        sampleStream.close();
      } catch (IOException e) {
        // sorry that this can fail
      }
    }
   
    System.out.println("done");

    System.out.println();

    System.out.println(evaluator.getFMeasure());
  }
View Full Code Here

TOP

Related Classes of opennlp.tools.tokenize.TokenizerEvaluator

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.