So i'm trying to use OpenNLP within Android Studio, but my application always throws a ParserConfigurationException within this body of code that is used by OpenNLP in their XmlUtil class, which that I am unable to modify:
public static DocumentBuilder createDocumentBuilder() {
try {
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setFeature("http://javax.xml.XMLConstants/feature/secure-processing", true);
return documentBuilderFactory.newDocumentBuilder();
} catch (ParserConfigurationException var1) {
throw new IllegalStateException(var1);
}
}
documentBuilderFactory.setFeature("http://javax.xml.XMLConstants/feature/secure-processing", true); causes the application to throw a ParserConfigurationException.
Been stuck on this for about a week now and no luck, any tips for how I can get around this error?
I had the same problem using version 1.9.1 of OpenNLP and I solved this by using version 1.6.0 instead. This is the latest version I've managed to get working.
dependencies {
implementation 'org.apache.opennlp:opennlp-tools:1.6.0'
}
Downgrading was seamless since the models are the same and the public API is largely similar (at least for my use).
Full story: I was making a prototype with OpenNLP to use a TokenizerME and two NameFinderME -- for persons and locations. These are all the versions of OpenNLP I've tried (and failed with):
ParserConfigurationException described in the OPOutOfMemoryError when trying to load the NameFinderMEIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With