use of com.graphaware.nlp.extension.NLPExtension in project neo4j-nlp by graphaware.
the class NLPManager method loadExtensions.
private void loadExtensions() {
Map<String, NLPExtension> extensionMap = ServiceLoader.loadInstances(NLPModuleExtension.class);
extensionMap.keySet().forEach(k -> {
NLPExtension extension = extensionMap.get(k);
extension.postLoaded();
extensions.put(extension.getClass(), extensionMap.get(k));
});
}
use of com.graphaware.nlp.extension.NLPExtension in project neo4j-nlp by graphaware.
the class ServiceLoader method loadNLPExtension.
public static NLPExtension loadNLPExtension(String extensionClazz) {
NLPExtension extension;
try {
@SuppressWarnings("unchecked") Class<? extends NLPExtension> clazz = (Class<? extends NLPExtension>) Class.forName(extensionClazz);
NLPExtension classInstance = clazz.newInstance();
if (classInstance instanceof TextProcessor) {
extension = (NLPExtension) classInstance;
// datumSerializer.configure(filterContext);
} else {
throw new IllegalArgumentException(extensionClazz + " is not an NLP Extension");
}
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException e) {
LOG.error("Could not instantiate event filter.", e);
throw new RuntimeException("Could not instantiate event filter.", e);
}
return extension;
}
Aggregations