Examples of SentenceModel


Examples of opennlp.tools.sentdetect.SentenceModel

    String sdModelPath = (String) context
        .getConfigParameterValue(SD_MODEL_FILE_PARAM);
      InputStream is = FileLocator.getAsStream(sdModelPath);
      logger.info("Sentence detector model file: " + sdModelPath);
      sdmodel = new SentenceModel(is);
      is.close();
      EndOfSentenceScannerImpl eoss = new EndOfSentenceScannerImpl();
      char[] eosc = eoss.getEndOfSentenceCharacters();
      // SentenceDContextGenerator cg = new SentenceDContextGenerator();
      DefaultSDContextGenerator cg = new DefaultSDContextGenerator(eosc);
View Full Code Here

Examples of opennlp.tools.sentdetect.SentenceModel

  public void initialize(UimaContext aContext)
      throws ResourceInitializationException {
    super.initialize(aContext);
    try (InputStream is = FileLocator.getAsStream(sdModelPath)){
      logger.info("Sentence detector model file: " + sdModelPath);
      sdmodel = new SentenceModel(is);
      EndOfSentenceScannerImpl eoss = new EndOfSentenceScannerImpl();
      DefaultSDContextGenerator cg = new DefaultSDContextGenerator(eoss.getEndOfSentenceCharacters());
      sentenceDetector = new SentenceDetectorCtakes(
          sdmodel.getMaxentModel(), cg, eoss);
View Full Code Here

Examples of opennlp.tools.sentdetect.SentenceModel

    logger.info("Training new model from " + inFile.getAbsolutePath());
    logger.info("Using " + numEosc + " end of sentence characters.");


    Charset charset = Charset.forName("UTF-8");
    SentenceModel mod = null;
   
    try(FileInputStream inStream = new FileInputStream(inFile)){
      ObjectStream<String> lineStream = new PlainTextByLineStream(inStream, charset);
      ObjectStream<SentenceSample> sampleStream = new SentenceSampleStream(lineStream);

      // Training Parameters
      TrainingParameters mlParams = new TrainingParameters();
      mlParams.put(TrainingParameters.ALGORITHM_PARAM, "MAXENT");
      mlParams.put(TrainingParameters.ITERATIONS_PARAM, Integer.toString(iters));
      mlParams.put(TrainingParameters.CUTOFF_PARAM, Integer.toString(cut));

      // Abbreviations dictionary
      // TODO: Actually import a Dictionary of abbreviations
      Dictionary dict = new Dictionary();

      try {
        mod = SentenceDetectorME.train("en", sampleStream, true, dict, mlParams);
      } finally {
        sampleStream.close();
      }
    }
   
    try(FileOutputStream outStream = new FileOutputStream(outFile)){
      logger.info("Saving the model as: " + outFile.getAbsolutePath());
      mod.serialize(outStream);
    }
  }
View Full Code Here

Examples of opennlp.tools.sentdetect.SentenceModel

                getResourceAsStream(chunkerModelFile)));
    }

    public static SentenceDetector getDefaultSentenceDetector()
            throws IOException {
        return new SentenceDetectorME(new SentenceModel(
                getResourceAsStream(sentDetectorModelFile)));
    }
View Full Code Here

Examples of opennlp.tools.sentdetect.SentenceModel

      GISModel sentModel = GIS.trainModel(hses, iterations, cutoff);

      manifestInfoEntries.put(BaseModel.TRAINING_EVENTHASH_PROPERTY,
          hses.calculateHashSum().toString(16));
     
      return new SentenceModel(languageCode, sentModel,
          useTokenEnd, abbreviations, manifestInfoEntries);
    }
View Full Code Here

Examples of opennlp.tools.sentdetect.SentenceModel

        if ((lang == null) || (encoding == null)) {
          usage();
        }

       
        SentenceModel model = train(lang, new SentenceSampleStream(new PlainTextByLineStream(
            new InputStreamReader(new FileInputStream(inFile), encoding))), true, null, cutoff, iters);

        // TODO: add support for iterations and cutoff settings

//        if (args.length > ai)
//          mod = train(es, Integer.parseInt(args[ai++]), Integer.parseInt(args[ai++]));
//        else
//          mod = train(es, 100, 5);

        System.out.println("Saving the model as: " + outFile);
        model.serialize(new FileOutputStream(outFile));
      }
      catch (Exception e) {
        e.printStackTrace();
      }
    }
View Full Code Here

Examples of opennlp.tools.sentdetect.SentenceModel

    String sdModelPath = (String) context
        .getConfigParameterValue(SD_MODEL_FILE_PARAM);
      InputStream is = FileLocator.getAsStream(sdModelPath);
      logger.info("Sentence detector model file: " + sdModelPath);
      sdmodel = new SentenceModel(is);
      is.close();
      EndOfSentenceScannerImpl eoss = new EndOfSentenceScannerImpl();
      char[] eosc = eoss.getEndOfSentenceCharacters();
      // SentenceDContextGenerator cg = new SentenceDContextGenerator();
      DefaultSDContextGenerator cg = new DefaultSDContextGenerator(eosc);
View Full Code Here

Examples of opennlp.tools.sentdetect.SentenceModel

                mdl = new POSModel(in);
                LOG.debug("OpenNLP5 POS Model loaded: " + mdl);
                break;
            }
            case SentenceModel: {
                mdl = new SentenceModel(in);
                LOG.debug("OpenNLP5 Sentence Model loaded: " + mdl);
                break;
            }
            case ChunkModel: {
                mdl = new ChunkerModel(in);
View Full Code Here

Examples of opennlp.tools.sentdetect.SentenceModel

     * @throws IOException
     */
    public ApacheExtractor() throws IOException {
        nameFinder = new NameFinderME(new TokenNameFinderModel(ApacheExtractor.class.getResourceAsStream(pathToNERModel)));
        tokenizer = new TokenizerME(new TokenizerModel(ApacheExtractor.class.getResourceAsStream(pathToTokenizerModel)));
        sentenceDetector = new SentenceDetectorME(new SentenceModel(ApacheExtractor.class.getResourceAsStream(pathToSentenceDetectorModel)));
    }
View Full Code Here

Examples of opennlp.tools.sentdetect.SentenceModel

     * @param language
     * @return
     */
    private SentenceModel getSentenceModel(String language) {
        try {
            SentenceModel model = openNLP.getSentenceModel(language);
            if(model != null){
                return model;
            } else { //fallback to english
                log.info("No sentence detection modle for {}. fallback to English");   
                model = openNLP.getSentenceModel("en");
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.