Examples of POSModel


Examples of opennlp.tools.postag.POSModel

        SentenceDetector sentDetector = openNLP.getSentenceDetector("ru");
        Assert.assertNull(sentDetector);
    }
    @Test
    public void testLoadEnPOS() throws IOException{
        POSModel model = openNLP.getPartOfSpeachModel("en");
        Assert.assertNotNull(model);
        POSTagger posTagger = openNLP.getPartOfSpeechTagger("en");
        Assert.assertNotNull(posTagger);
    }
View Full Code Here

Examples of opennlp.tools.postag.POSModel

        POSTagger posTagger = openNLP.getPartOfSpeechTagger("en");
        Assert.assertNotNull(posTagger);
    }
    @Test
    public void testLoadMissingPOS() throws IOException{
        POSModel model = openNLP.getPartOfSpeachModel("ru");
        Assert.assertNull(model);
        POSTagger posTagger = openNLP.getPartOfSpeechTagger("ru");
        Assert.assertNull(posTagger);
    }
View Full Code Here

Examples of opennlp.tools.postag.POSModel

    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);
        TokenNameFinderModel nerModel = openNLP.getModel(TokenNameFinderModel.class, "en-ner-person.bin", null);
        Assert.assertNotNull(nerModel);
View Full Code Here

Examples of opennlp.tools.postag.POSModel

     */
    public POSModel getPartOfSpeachModel(String language) throws IOException, InvalidFormatException {
        //typically there are two versions
        //we prefer the perceptron variant but if not available try to build the other
        IOException first = null;
        POSModel model;
        try {
            model = initModel(String.format("%s-pos-perceptron.bin",language), POSModel.class);
        } catch (IOException e) {
            first = e;
            log.warn("Unable to laod preceptron based POS model for "+language,e);
View Full Code Here

Examples of opennlp.tools.postag.POSModel

     * @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 POSTagger getPartOfSpeechTagger(String language) throws IOException {
        POSModel posModel = getPartOfSpeachModel(language);
        if(posModel != null){
            return new POSTaggerME(posModel);
        } else {
            log.debug("No POS Model for language '{}'",language);
            return null;
View Full Code Here

Examples of opennlp.tools.postag.POSModel

        return new TokenizerME(new TokenizerModel(
                getResourceAsStream(tokenizerModelFile)));
    }

    public static POSTagger getDefaultPosTagger() throws IOException {
        return new POSTaggerME(new POSModel(
                getResourceAsStream(taggerModelFile)));
    }
View Full Code Here

Examples of opennlp.tools.postag.POSModel

    try {
      posModelPath = (String) uimaContext
          .getConfigParameterValue(POS_MODEL_FILE_PARAM);
      logger.info("POS tagger model file: " + posModelPath);
      fis = FileLocator.getAsStream(posModelPath);
      POSModel modelFile = new POSModel(fis);
      tagger = new opennlp.tools.postag.POSTaggerME(modelFile);
      fis.close();
    } catch (Exception e) {
      logger.info("Error loading POS tagger model: " + posModelPath);
      throw new ResourceInitializationException(e);
View Full Code Here

Examples of opennlp.tools.postag.POSModel

        hsbes.calculateHashSum().toString(16));
   
    parseSamples.reset();
   
    // tag
    POSModel posModel = POSTaggerME.train(languageCode, new PosSampleStream(parseSamples),
        ModelType.MAXENT, null, null, cut, iterations);
   
    parseSamples.reset();
   
    // chunk
View Full Code Here

Examples of opennlp.tools.postag.POSModel

    }
   
    if (tag || all) {
      System.err.println("Training tagger");
      ObjectStream<POSSample> tes = new PosSampleStream(new ParseSampleStream(new PlainTextByLineStream(new java.io.FileReader(inFile))));
      POSModel posModel = POSTaggerME.train("en", tes, ModelType.MAXENT, null, null, cutoff, 100);
      System.out.println("Saving the tagger model as: " + tagFile);
      OutputStream posOutputStream = new FileOutputStream(tagFile);
      posModel.serialize(posOutputStream);
      posOutputStream.close();
    }

    if (chunk || all) {
      System.err.println("Training chunker");
View Full Code Here

Examples of opennlp.tools.postag.POSModel

                mdl = new TokenizerModel(in);
                LOG.debug("OpenNLP5 Tokenizer Model loaded: " + mdl);
                break;
            }
            case POSModel: {
                mdl = new POSModel(in);
                LOG.debug("OpenNLP5 POS Model loaded: " + mdl);
                break;
            }
            case SentenceModel: {
                mdl = new SentenceModel(in);
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.