Search in sources :

Example 1 with LanguageManager

use of com.graphaware.nlp.language.LanguageManager in project neo4j-nlp by graphaware.

the class NLPManager method init.

public void init(GraphDatabaseService database, DynamicConfiguration configuration) {
    if (initialized) {
        return;
    }
    this.configuration = configuration;
    this.languageManager = new LanguageManager();
    this.database = database;
    this.persistenceRegistry = new PersistenceRegistry(database);
    this.enrichmentRegistry = buildAndRegisterEnrichers();
    this.eventDispatcher = new EventDispatcher();
    loadExtensions();
    if (textProcessorsManager == null) {
        this.textProcessorsManager = new TextProcessorsManager(configuration);
    }
    this.textProcessorsManager.registerPipelinesFromConfig();
    loadVectorComputationProcesses();
    loadSummarizers();
    registerWord2VecModelFromConfig();
    initialized = true;
}
Also used : PersistenceRegistry(com.graphaware.nlp.persistence.PersistenceRegistry) EventDispatcher(com.graphaware.nlp.event.EventDispatcher) TextProcessorsManager(com.graphaware.nlp.processor.TextProcessorsManager) LanguageManager(com.graphaware.nlp.language.LanguageManager)

Example 2 with LanguageManager

use of com.graphaware.nlp.language.LanguageManager in project neo4j-nlp by graphaware.

the class NLPManager method checkTextLanguage.

public String checkTextLanguage(String text, boolean failIfUnsupported) {
    LanguageManager languageManager = LanguageManager.getInstance();
    String detectedLanguage = languageManager.detectLanguage(text);
    if (!languageManager.isTextLanguageSupported(text) && configuration.hasSettingValue(SettingsConstants.FALLBACK_LANGUAGE)) {
        return configuration.getSettingValueFor(SettingsConstants.FALLBACK_LANGUAGE).toString();
    }
    if (!languageManager.isTextLanguageSupported(text) && failIfUnsupported) {
        String msg = String.format("Unsupported language : %s", detectedLanguage);
        LOG.error(msg);
        throw new RuntimeException(msg);
    }
    return detectedLanguage;
}
Also used : LanguageManager(com.graphaware.nlp.language.LanguageManager)

Aggregations

LanguageManager (com.graphaware.nlp.language.LanguageManager)2 EventDispatcher (com.graphaware.nlp.event.EventDispatcher)1 PersistenceRegistry (com.graphaware.nlp.persistence.PersistenceRegistry)1 TextProcessorsManager (com.graphaware.nlp.processor.TextProcessorsManager)1