use of opennlp.tools.namefind.TokenNameFinderModel in project tika by apache.
the class GeoParser method initialize.
/**
* Initializes this parser
* @param modelUrl the URL to NER model
*/
public void initialize(URL modelUrl) {
try {
if (this.modelUrl != null && this.modelUrl.toURI().equals(modelUrl.toURI())) {
return;
}
} catch (URISyntaxException e1) {
throw new RuntimeException(e1.getMessage());
}
this.modelUrl = modelUrl;
gazetteerClient = new GeoGazetteerClient(config);
// Check if the NER model is available, and if the
// lucene-geo-gazetteer is available
this.available = modelUrl != null && gazetteerClient.checkAvail();
if (this.available) {
try {
TokenNameFinderModel model = new TokenNameFinderModel(modelUrl);
this.nameFinder = new NameFinderME(model);
} catch (Exception e) {
LOG.warn("Named Entity Extractor setup failed: {}", e.getMessage(), e);
this.available = false;
}
}
initialized = true;
}
use of opennlp.tools.namefind.TokenNameFinderModel in project stanbol by apache.
the class OpenNLPTest method testLoadEnNER.
@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);
}
}
Aggregations