use of org.apache.tika.parser.geo.topic.gazetteer.GeoGazetteerClient 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;
}
Aggregations