Search in sources :

Example 1 with NLPExtension

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));
    });
}
Also used : NLPExtension(com.graphaware.nlp.extension.NLPExtension)

Example 2 with NLPExtension

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;
}
Also used : NLPExtension(com.graphaware.nlp.extension.NLPExtension) TextProcessor(com.graphaware.nlp.processor.TextProcessor)

Aggregations

NLPExtension (com.graphaware.nlp.extension.NLPExtension)2 TextProcessor (com.graphaware.nlp.processor.TextProcessor)1