Package opennlp.tools.cmdline

Examples of opennlp.tools.cmdline.TerminateToolException


      detokenizer = new DictionaryDetokenizer(new DetokenizationDictionary(
          new FileInputStream(new File(params.getDetokenizer()))));
    } catch (IOException e) {
      System.err.println("Error while loading detokenizer dict: "
          + e.getMessage());
      throw new TerminateToolException(-1);
    }

    return new POSToSentenceSampleStream(detokenizer, posSampleStream, 30);
  }
View Full Code Here


    else if ("es".equals(params.getLang())) {
      lang = LANGUAGE.ES;
    }
    else {
      System.err.println("Unsupported language: " + params.getLang());
      throw new TerminateToolException(-1);
    }
   
    int typesToGenerate = 0;
   
    if (params.getTypes().contains("per")) {
View Full Code Here

          CmdLineUtil.openInFile(new File(params.getData())), params.getEncoding()));
     
      return new NameSampleDataStream(lineStream);
    } catch (UnsupportedEncodingException e) {
      System.err.println("Encoding not supported: " + params.getEncoding());
      throw new TerminateToolException(-1);
    }
  }
View Full Code Here

          CmdLineUtil.openInFile(new File(params.getData())), params.getEncoding()));
     
      return new ConllXPOSSampleStream(lineStream);
    } catch (UnsupportedEncodingException e) {
      System.err.println("Encoding not supported: " + params.getEncoding());
      throw new TerminateToolException(-1);
    }
  }
View Full Code Here

    Detokenizer detokenizer;
    try {
      detokenizer = new DictionaryDetokenizer(new DetokenizationDictionary(new FileInputStream(new File(params.getDetokenizer()))));
    } catch (IOException e) {
      System.err.println("Error while loading detokenizer dict: " + e.getMessage());
      throw new TerminateToolException(-1);
    }
   
    return new POSToTokenSampleStream(detokenizer,samples);
  }
View Full Code Here

    else if ("de".equals(params.getLang())) {
      lang = LANGUAGE.DE;
    }
    else {
      System.err.println("Unsupported language: " + params.getLang());
      throw new TerminateToolException(-1);
    }

    int typesToGenerate = 0;

    if (params.getTypes().contains("per")) {
View Full Code Here

  }

  public void run(String[] args) {
    if (args.length != 0) {
      System.out.println(getHelp());
      throw new TerminateToolException(1);
    }
   
    CommandLineTokenizer tokenizer =
      new CommandLineTokenizer(opennlp.tools.tokenize.SimpleTokenizer.INSTANCE);
   
View Full Code Here

 
  public void run(String[] args) {
   
    if (args.length == 0) {
      System.out.println(getHelp());
      throw new TerminateToolException(1);
    }
   
    NameFinderME nameFinders[] = new NameFinderME[args.length];
   
    for (int i = 0; i < nameFinders.length; i++) {
View Full Code Here

  }

  public void run(String[] args) {
    if (!ArgumentParser.validateArguments(args, TrainerToolParams.class)) {
      System.err.println(getHelp());
      throw new TerminateToolException(1);
    }
   
    TrainerToolParams params = ArgumentParser.parse(args,
        TrainerToolParams.class);

    opennlp.tools.util.TrainingParameters mlParams =
      CmdLineUtil.loadTrainingParameters(params.getParams(), false);
   
    if (mlParams != null) {
      if (!TrainUtil.isValid(mlParams.getSettings())) {
        System.err.println("Training parameters file is invalid!");
        throw new TerminateToolException(-1);
      }
     
      if (TrainUtil.isSequenceTraining(mlParams.getSettings())) {
        System.err.println("Sequence training is not supported!");
        throw new TerminateToolException(-1);
      }
    }
   
    File trainingDataInFile = params.getData();
    File modelOutFile = params.getModel();
   
    CmdLineUtil.checkOutputFile("tokenizer model", modelOutFile);
    ObjectStream<TokenSample> sampleStream = openSampleData("Training",
        trainingDataInFile, params.getEncoding());
   
    if(mlParams == null)
      mlParams = createTrainingParameters(params.getIterations(), params.getCutoff());

    TokenizerModel model;
    try {
      Dictionary dict = loadDict(params.getAbbDict());
      model = opennlp.tools.tokenize.TokenizerME.train(params.getLang(),
          sampleStream, dict, params.getAlphaNumOpt(), mlParams);
    } catch (IOException e) {
      CmdLineUtil.printTrainingIoError(e);
      throw new TerminateToolException(-1);
    }
    finally {
      try {
        sampleStream.close();
      } catch (IOException e) {
View Full Code Here

  }

  public void run(String[] args) {
    if (!ArgumentParser.validateArguments(args, CVToolParams.class)) {
      System.err.println(getHelp());
      throw new TerminateToolException(1);
    }
   
    CVToolParams params = ArgumentParser.parse(args, CVToolParams.class);
   
    opennlp.tools.util.TrainingParameters mlParams = CmdLineUtil
        .loadTrainingParameters(params.getParams(), false);
   
    File trainingDataInFile = params.getData();
    CmdLineUtil.checkInputFile("Training Data", trainingDataInFile);
   
    Charset encoding = params.getEncoding();
   
    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) {
View Full Code Here

TOP

Related Classes of opennlp.tools.cmdline.TerminateToolException

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.