Package opennlp.tools.namefind

Examples of opennlp.tools.namefind.TokenNameFinderModel$FeatureGeneratorCreationError


        private Map<String,String> registeredModels = Collections.synchronizedMap(
            new HashMap<String,String>());
       
        @Override
        public boolean available(String resourceName, InputStream is) {
            TokenNameFinderModel model;
            try {
                model = openNLP.getModel(TokenNameFinderModel.class, resourceName, null);
                //register the new model to the configuration
                String modelLang = model.getLanguage().toLowerCase();
                log.info("register custom NameFinderModel from resource: {} for language: {} to {} (name:{})",
                    new Object[]{resourceName,model.getLanguage(),getClass().getSimpleName(),getName()});
                String currentLang = registeredModels.remove(resourceName);
                if(currentLang != null && !modelLang.equals(currentLang)){
                    config.removeCustomNameFinderModel(currentLang, resourceName);
                }
                config.addCustomNameFinderModel(modelLang, resourceName);
View Full Code Here


            }
            case person:
            case organization:
            case location:
            {
                mdl = new TokenNameFinderModel(in);
                LOG.debug("OpenNLP5 TokenNameFinderModel Model loaded: " + mdl);
                break;
            }
            default: LOG.debug("Unknown Model Type!");
View Full Code Here

     * Name Finder and Tokenizer.
     *
     * @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

            }
        }
        try {
            if(config.isProcessedLangage(language)){
                for (String defaultModelType : config.getDefaultModelTypes()) {
                    TokenNameFinderModel nameFinderModel = openNLP.getNameModel(defaultModelType, language);
                    if(nameFinderModel == null){
                        log.info("No NER Model for {} and language {} available!",defaultModelType,language);
                    } else {
                        findNamedEntities(ci, at, text, language, nameFinderModel);
                    }
                }
            } //else do not use default models for languages other than the processed one
            //process for additional models
            for(String additionalModel : config.getSpecificNerModles(language)){
                TokenNameFinderModel nameFinderModel;
                try {
                    nameFinderModel = openNLP.getModel(TokenNameFinderModel.class,
                        additionalModel, null);
                    findNamedEntities(ci, at, text, language, nameFinderModel);
                } catch (IOException e) {
View Full Code Here

     * @param language the language for the model
     * @return the model or an {@link IllegalStateException} if not available
     */
    private TokenNameFinderModel getNameModel(String type,String language) {
        try {
            TokenNameFinderModel model = openNLP.getNameModel(type, language);
            if(model != null){
                return model;
            } else {
                throw new IllegalStateException(String.format(
                    "Unable to built Model for extracting %s from '%s' language " +
View Full Code Here

        private Map<String,String> registeredModels = Collections.synchronizedMap(
            new HashMap<String,String>());
       
        @Override
        public boolean available(String resourceName, InputStream is) {
            TokenNameFinderModel model;
            try {
                model = openNLP.getModel(TokenNameFinderModel.class, resourceName, null);
                //register the new model to the configuration
                String modelLang = model.getLanguage().toLowerCase();
                log.info("register custom NameFinderModel from resource: {} for language: {} to {} (name:{})",
                    new Object[]{resourceName,model.getLanguage(),getClass().getSimpleName(),getName()});
                String currentLang = registeredModels.remove(resourceName);
                if(currentLang != null && !modelLang.equals(currentLang)){
                    config.removeCustomNameFinderModel(currentLang, resourceName);
                }
                config.addCustomNameFinderModel(modelLang, resourceName);
View Full Code Here

  }

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

    TokenNameFinderModel model = new TokenNameFinderModelLoader().load(params.getModel());

    List<EvaluationMonitor<NameSample>> listeners = new LinkedList<EvaluationMonitor<NameSample>>();
    if (params.getMisclassified()) {
      listeners.add(new NameEvaluationErrorListener());
    }
View Full Code Here

  }

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

    } else {

      NameFinderME nameFinders[] = new NameFinderME[args.length];

      for (int i = 0; i < nameFinders.length; i++) {
        TokenNameFinderModel model = new TokenNameFinderModelLoader().load(new File(args[i]));
        nameFinders[i] = new NameFinderME(model);
      }

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

          featureGeneratorBytes, resources, sequenceCodec);
    } catch (InvalidFormatException e) {
      throw new TerminateToolException(-1, e.getMessage(), e);
    }

    TokenNameFinderModel model;
    try {
      model = opennlp.tools.namefind.NameFinderME.train(
          params.getLang(), params.getType(), sampleStream, mlParams,
          nameFinderFactory);
    }
View Full Code Here

TOP

Related Classes of opennlp.tools.namefind.TokenNameFinderModel$FeatureGeneratorCreationError

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.