Examples of SentenceModel


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

    char[] eos = null;
    if (params.getEosChars() != null)
      eos = params.getEosChars().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

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

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

      SentenceDetectorME sdetector = new SentenceDetectorME(model);

      ObjectStream<String> paraStream =
        new ParagraphStream(new PlainTextByLineStream(new InputStreamReader(System.in)));
View Full Code Here

Examples of opennlp.tools.sentdetect.SentenceModel

        if(!config.enableSentenceDetector){
            return null;
        }
        if(sentenceDetector == null && !sentenceDetectorNotAvailable){
            try {
                SentenceModel sentModel = openNLP.getSentenceModel(language);
                if(sentModel != null){
                    sentenceDetector = new SentenceDetectorME(sentModel);
                } else {
                    log.debug("No Sentence Detection Model for language '{}'",language);
                    sentenceDetectorNotAvailable = true;
View Full Code Here

Examples of opennlp.tools.sentdetect.SentenceModel

        Assert.assertEquals(SimpleTokenizer.INSTANCE, tokenizer);
    }
   
    @Test
    public void testLoadEnSentence() throws IOException{
        SentenceModel model = openNLP.getSentenceModel("en");
        Assert.assertNotNull(model);
        SentenceDetector sentDetector = openNLP.getSentenceDetector("en");
        Assert.assertNotNull(sentDetector);
    }
View Full Code Here

Examples of opennlp.tools.sentdetect.SentenceModel

        SentenceDetector sentDetector = openNLP.getSentenceDetector("en");
        Assert.assertNotNull(sentDetector);
    }
    @Test
    public void testLoadMissingSentence() throws IOException{
        SentenceModel model = openNLP.getSentenceModel("ru");
        Assert.assertNull(model);
        SentenceDetector sentDetector = openNLP.getSentenceDetector("ru");
        Assert.assertNull(sentDetector);
    }
View Full Code Here

Examples of opennlp.tools.sentdetect.SentenceModel

    }
    @Test
    public void testLoadModelByName() throws IOException{
        TokenizerModel tokenModel = openNLP.getModel(TokenizerModel.class, "en-token.bin", null);
        Assert.assertNotNull(tokenModel);
        SentenceModel sentModel = openNLP.getModel(SentenceModel.class, "en-sent.bin", null);
        Assert.assertNotNull(sentModel);
        POSModel posModel = openNLP.getModel(POSModel.class, "en-pos-maxent.bin", null);
        Assert.assertNotNull(posModel);
        ChunkerModel chunkModel = openNLP.getModel(ChunkerModel.class, "en-chunker.bin", null);
        Assert.assertNotNull(chunkModel);
View Full Code Here

Examples of opennlp.tools.sentdetect.SentenceModel

        tokenModel = openNLP.getModel(TokenizerModel.class, "ru-token.bin", null);
        Assert.assertNull(tokenModel);
    }
    @Test(expected=IllegalStateException.class)
    public void testLoadIncompatibleModelByName() throws IOException{
        SentenceModel sentModel = openNLP.getModel(SentenceModel.class, "en-token.bin", null);
        Assert.assertNotNull(sentModel);
    }
View Full Code Here

Examples of opennlp.tools.sentdetect.SentenceModel

     * @return the model or <code>null</code> if no model data are found
     * @throws InvalidFormatException in case the found model data are in the wrong format
     * @throws IOException on any error while reading the model data
     */
    public SentenceDetector getSentenceDetector(String language) throws IOException {
        SentenceModel sentModel = getSentenceModel(language);
        if(sentModel != null){
            return new SentenceDetectorME(sentModel);
        } else {
            log.debug("No Sentence Detection Model for language '{}'",language);
            return null;
View Full Code Here

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
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.