Search in sources :

Example 1 with GeoGazetteerClient

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;
}
Also used : TokenNameFinderModel(opennlp.tools.namefind.TokenNameFinderModel) GeoGazetteerClient(org.apache.tika.parser.geo.topic.gazetteer.GeoGazetteerClient) NameFinderME(opennlp.tools.namefind.NameFinderME) URISyntaxException(java.net.URISyntaxException) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) TikaException(org.apache.tika.exception.TikaException) SAXException(org.xml.sax.SAXException)

Aggregations

IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 NameFinderME (opennlp.tools.namefind.NameFinderME)1 TokenNameFinderModel (opennlp.tools.namefind.TokenNameFinderModel)1 TikaException (org.apache.tika.exception.TikaException)1 GeoGazetteerClient (org.apache.tika.parser.geo.topic.gazetteer.GeoGazetteerClient)1 SAXException (org.xml.sax.SAXException)1