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;
}
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;
}
Aggregations