Examples of SentenceModel


Examples of opennlp.tools.sentdetect.SentenceModel

     * @param language the language
     * @return the model of <code>null</code> if non is available or
     * an exception was encountered while loading
     */
    private SentenceDetector getSentenceDetector(String language) {
        SentenceModel model;
        String modelName = languageConfig.getParameter(language, MODEL_NAME_PARAM);
        if(modelName == null){
            try {
                model = openNLP.getSentenceModel(language);
            } catch (Exception e) {
                log.warn("Unable to load default Sentence Detection model for language '"+language+"'!",e);
                return null;
            }
        } else {
            try {
                model = openNLP.getModel(SentenceModel.class, modelName, null);
            } catch (Exception e) {
                log.warn("Unable to load Sentence Detection model for language '"
                        +language+"' from the configured model '"+modelName+"'!",e);
                return null;
            }
        }
        if(model != null) {
            log.debug("Sentence Detection Model {} for lanugage '{}' version: {}",
                new Object[]{model.getClass().getSimpleName(),
                             model.getLanguage(),
                             model.getVersion() != null ? model.getVersion() : "undefined"});
            return new SentenceDetectorME(model);
        }
        log.debug("Sentence Detection Model for Language '{}' not available.", language);
        return null;
    }
View Full Code Here

Examples of opennlp.tools.sentdetect.SentenceModel

    if (args.length != 1) {
      System.out.println(getHelp());
    } else {

      SentenceModel model = new SentenceModelLoader().load(new File(args[0]));

      SentenceDetectorME sdetector = new SentenceDetectorME(model);

      PerformanceMonitor perfMon = new PerformanceMonitor(System.err, "sent");
      perfMon.start();
View Full Code Here

Examples of opennlp.tools.sentdetect.SentenceModel

  }

  @Override
  protected SentenceModel loadModel(InputStream modelIn) throws IOException,
      InvalidFormatException {
    return new SentenceModel(modelIn);
  }
View Full Code Here

Examples of opennlp.tools.sentdetect.SentenceModel

  }

  public void run(String format, String[] args) {
    super.run(format, args);

    SentenceModel model = new SentenceModelLoader().load(params.getModel());

    SentenceDetectorEvaluationMonitor errorListener = null;
    if (params.getMisclassified()) {
      errorListener = new SentenceEvaluationErrorListener();
    }
View Full Code Here

Examples of opennlp.tools.sentdetect.SentenceModel

      String eosString = SentenceSampleStream.replaceNewLineEscapeTags(
          params.getEosChars());
      eos = eosString.toCharArray();
    }

    SentenceModel model;

    try {
      Dictionary dict = loadDict(params.getAbbDict());
      SentenceDetectorFactory sdFactory = SentenceDetectorFactory.create(
          params.getFactory(), params.getLang(), true, dict, eos);
View Full Code Here

Examples of opennlp.tools.sentdetect.SentenceModel

    SentenceDetector sentDetector;

    if (params.getSentenceDetectorModel() != null) {
      try {
        sentDetector = new SentenceDetectorME(new SentenceModel(params.getSentenceDetectorModel()));
      } catch (IOException e) {
        throw new TerminateToolException(-1, "Failed to load sentence detector model!", e);
      }
    }
    else {
View Full Code Here

Examples of opennlp.tools.sentdetect.SentenceModel

    return model;
  }

  @Override
  protected SentenceModel loadModel(InputStream in) throws IOException {
    return new SentenceModel(in);
  }
View Full Code Here

Examples of opennlp.tools.sentdetect.SentenceModel

    if (sampleTraceFile != null) {
        samplesOut = new OutputStreamWriter(new FileOutputStream(sampleTraceFile), sampleTraceFileEncoding);
        samples = new SampleTraceStream<SentenceSample>(samples, samplesOut);
    }

    SentenceModel sentenceModel = SentenceDetectorME.train(language, samples,
         sdFactory, mlParams);

    // dereference to allow garbage collection
    sentenceSamples = null;
View Full Code Here

Examples of opennlp.tools.sentdetect.SentenceModel

  public void initialize(UimaContext context)
      throws ResourceInitializationException {

    super.initialize(context);

    SentenceModel model;

    try {
      SentenceModelResource modelResource = (SentenceModelResource) context
          .getResourceObject(UimaUtil.MODEL_PARAMETER);
View Full Code Here

Examples of opennlp.tools.sentdetect.SentenceModel

        sLogger.info("--> classifier model");
      }
    }

    InputStream modelIn = localFs.open(pathMapping.get(sentDetectorFile));
    SentenceModel model = new SentenceModel(modelIn);
    fModel = new SentenceDetectorME(model);
    sLogger.info("Sentence model created successfully from " + pathMapping.get(sentDetectorFile));

    eVocabSrc = (VocabularyWritable) HadoopAlign.loadVocab(pathMapping.get(eVocabSrcFile), localFs);
    eVocabTrg = (VocabularyWritable) HadoopAlign.loadVocab(pathMapping.get(eVocabTrgFile), localFs);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.