Package opennlp.tools.chunker

Examples of opennlp.tools.chunker.ChunkerCrossValidator


          Integer.toString(params.getIterations()));
      mlParams.put(TrainingParameters.CUTOFF_PARAM,
          Integer.toString(params.getCutoff()));
    }

    ChunkerCrossValidator validator = new ChunkerCrossValidator(
        params.getLang(), mlParams,
        listeners.toArray(new ChunkerEvaluationMonitor[listeners.size()]));
     
    try {
      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
      }
    }
   
    if (detailedFMeasureListener == null) {
      FMeasure result = validator.getFMeasure();
      System.out.println(result.toString());
    } else {
      System.out.println(detailedFMeasureListener.toString());
    }
  }
View Full Code Here


    if (params.getDetailedF()) {
      detailedFMeasureListener = new ChunkerDetailedFMeasureListener();
      listeners.add(detailedFMeasureListener);
    }

    ChunkerCrossValidator validator;

    try {
      ChunkerFactory chunkerFactory = ChunkerFactory
          .create(params.getFactory());

      validator = new ChunkerCrossValidator(params.getLang(), mlParams,
          chunkerFactory,
          listeners.toArray(new ChunkerEvaluationMonitor[listeners.size()]));
      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
      }
    }
   
    if (detailedFMeasureListener == null) {
      FMeasure result = validator.getFMeasure();
      System.out.println(result.toString());
    } else {
      System.out.println(detailedFMeasureListener.toString());
    }
  }
View Full Code Here

    if (params.getDetailedF()) {
      detailedFMeasureListener = new ChunkerDetailedFMeasureListener();
      listeners.add(detailedFMeasureListener);
    }

    ChunkerCrossValidator validator;

    try {
      ChunkerFactory chunkerFactory = ChunkerFactory
          .create(params.getFactory());

      validator = new ChunkerCrossValidator(params.getLang(), mlParams,
          chunkerFactory,
          listeners.toArray(new ChunkerEvaluationMonitor[listeners.size()]));
      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
      }
    }

    if (detailedFMeasureListener == null) {
      FMeasure result = validator.getFMeasure();
      System.out.println(result.toString());
    } else {
      System.out.println(detailedFMeasureListener.toString());
    }
  }
View Full Code Here

   
    ObjectStream<ChunkSample> sampleStream =
        ChunkerTrainerTool.openSampleData("Training Data",
        trainingDataInFile, parameters.getEncoding());
   
    ChunkerCrossValidator validator =
        new ChunkerCrossValidator(
            parameters.getLanguage(), parameters.getCutoff(), parameters.getNumberOfIterations());
     
    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.chunker.ChunkerCrossValidator

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.