Package opennlp.tools.chunker

Examples of opennlp.tools.chunker.ChunkerModel


        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);
        //unavailable model
        tokenModel = openNLP.getModel(TokenizerModel.class, "ru-token.bin", null);
View Full Code Here


     * @return the {@link Chunker} or <code>null</code> if no model is present
     * @throws InvalidFormatException in case the found model data are in the wrong format
     * @throws IOException on any error while reading the model data
     */
    public Chunker getChunker(String language) throws IOException {
        ChunkerModel chunkerModel = getChunkerModel(language);
        if(chunkerModel != null){
             return new ChunkerME(chunkerModel);
        } else {
            log.debug("No Chunker Model for language {}",language);
            return null;
View Full Code Here

   
  
    private ChunkerME initChunker(String language) {
        isLangaugeConfigured(this,languageConfiguration,language, true); //check if the parsed language is ok
        String modelName = languageConfiguration.getParameter(language, MODEL_PARAM_NAME);
        ChunkerModel model;
        try {
            if(modelName == null){ // the default model
                model = openNLP.getChunkerModel(language);
            } else {
                model = openNLP.getModel(ChunkerModel.class, modelName, null);
View Full Code Here

        return new POSTaggerME(new POSModel(
                getResourceAsStream(taggerModelFile)));
    }

    public static Chunker getDefaultChunker() throws IOException {
        return new ChunkerME(new ChunkerModel(
                getResourceAsStream(chunkerModelFile)));
    }
View Full Code Here

    String chunkerModelPath = null;
    try {
      chunkerModelPath = (String) uimaContext.getConfigParameterValue(CHUNKER_MODEL_FILE_PARAM);
      File chunkerModelFile = FileLocator.locateFile(chunkerModelPath);
      InputStream fis = new FileInputStream(chunkerModelFile);
      ChunkerModel model = new ChunkerModel(fis);
      String chunkerModelAbsPath = chunkerModelFile.getAbsolutePath();
      logger.info("Chunker model file: " + chunkerModelAbsPath);
                 
      chunker = new opennlp.tools.chunker.ChunkerME(model);
View Full Code Here

        ModelType.MAXENT, null, null, cut, iterations);
   
    parseSamples.reset();
   
    // chunk
    ChunkerModel chunkModel = ChunkerME.train(languageCode,
        new ChunkSampleStream(parseSamples), cut, iterations,
        new ChunkContextGenerator());
   
    parseSamples.reset();
   
View Full Code Here

    }

    if (chunk || all) {
      System.err.println("Training chunker");
      ObjectStream<ChunkSample> ces = new ChunkSampleStream(new ParseSampleStream(new PlainTextByLineStream(new java.io.FileReader(inFile))));
      ChunkerModel chunkModel = ChunkerME.train("en", ces, cutoff, iterations,
          new ChunkContextGenerator());
      System.out.println("Saving the chunker model as: " + chunkFile);
      OutputStream chunkOutputStream = new FileOutputStream(chunkFile);
      chunkModel.serialize(chunkOutputStream);
      chunkOutputStream.close();
    }

    if (build || all) {
      System.err.println("Loading Dictionary");
View Full Code Here

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

      }
      if (posModel == null) {
        posModel = new POSModel(Tools.getStream(POS_TAGGER_MODEL));
      }
      if (chunkerModel == null) {
        chunkerModel = new ChunkerModel(Tools.getStream(CHUNKER_MODEL));
      }
      chunkFilter = new EnglishChunkFilter();
    } catch (IOException e) {
      throw new RuntimeException("Could not initialize English chunker", e);
    }
View Full Code Here

   
  
    private ChunkerME initChunker(String language) {
        isLangaugeConfigured(this,languageConfiguration,language, true); //check if the parsed language is ok
        String modelName = languageConfiguration.getParameter(language, MODEL_PARAM_NAME);
        ChunkerModel model;
        try {
            if(modelName == null){ // the default model
                model = openNLP.getChunkerModel(language);
            } else {
                model = openNLP.getModel(ChunkerModel.class, modelName, null);
View Full Code Here

TOP

Related Classes of opennlp.tools.chunker.ChunkerModel

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.