Package opennlp.tools.namefind

Examples of opennlp.tools.namefind.TokenNameFinderModel


  public void initialize()
      throws ResourceInitializationException

    super.initialize();
   
    TokenNameFinderModel model;
   
    try {
      TokenNameFinderModelResource modelResource =
            (TokenNameFinderModelResource) context.getResourceObject(UimaUtil.MODEL_PARAMETER);
       
View Full Code Here


    }
    TreebankNameFinder[] finders = new TreebankNameFinder[args.length-ai];
    String[] names = new String[args.length-ai];
    for (int fi=0; ai < args.length; ai++,fi++) {
      String modelName = args[ai];
      finders[fi] = new TreebankNameFinder(new TokenNameFinderModel(new FileInputStream(modelName)));
      int nameStart = modelName.lastIndexOf(System.getProperty("file.separator")) + 1;
      int nameEnd = modelName.indexOf('.', nameStart);
      if (nameEnd == -1) {
        nameEnd = modelName.length();
      }
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

    if (params.getNameTypes() != null) {
      String nameTypes[] = params.getNameTypes().split(",");
      sampleStream = new NameSampleTypeFilter(nameTypes, sampleStream);
    }
   
    TokenNameFinderModel model;
    try {
      model = opennlp.tools.namefind.NameFinderME.train(
          params.getLang(), params.getType(), sampleStream,
          mlParams, featureGeneratorBytes, resources);
    }
View Full Code Here

        Assert.assertNull(chunker);
    }   
    @Test
    public void testLoadEnNER() throws IOException{
        for(String type : Arrays.asList("person","organization","location")){
            TokenNameFinderModel model = openNLP.getNameModel(type, "en");
            Assert.assertNotNull(model);
            TokenNameFinder ner = openNLP.getNameFinder(type, "en");
            Assert.assertNotNull(ner);
        }
    }
View Full Code Here

        }
    }
    @Test
    public void testLoadMissingNER() throws IOException{
        //first unknown type
        TokenNameFinderModel model = openNLP.getNameModel("person2", "en");
        Assert.assertNull(model);
        TokenNameFinder ner = openNLP.getNameFinder("person2", "en");
        Assert.assertNull(ner);
        //unknown language
        model = openNLP.getNameModel("person", "ru");
View Full Code Here

        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);
        Assert.assertNull(tokenModel);
    }
View Full Code Here

     * @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 TokenNameFinder getNameFinder(String type, String language) throws IOException {
        TokenNameFinderModel model = getNameModel(type, language);
        if(model != null){
            return new NameFinderME(model);
        } else {
            log.debug("TokenNameFinder model for type {} and langauge {} not present",type,language);
            return null;
View Full Code Here

TOP

Related Classes of opennlp.tools.namefind.TokenNameFinderModel

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.