From 18d687d86e183c5cea60338eb2061a2eb35b76ac Mon Sep 17 00:00:00 2001 From: SrdjanStevanetic Date: Tue, 28 Nov 2023 11:52:55 +0100 Subject: [PATCH] added lang hint for apache-tika (comment out) --- .../apachetika/ApacheTikaLangDetectService.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/translation-service-apache-tika/src/main/java/eu/europeana/translation/service/apachetika/ApacheTikaLangDetectService.java b/translation-service-apache-tika/src/main/java/eu/europeana/translation/service/apachetika/ApacheTikaLangDetectService.java index a368b3d2..8c47601f 100644 --- a/translation-service-apache-tika/src/main/java/eu/europeana/translation/service/apachetika/ApacheTikaLangDetectService.java +++ b/translation-service-apache-tika/src/main/java/eu/europeana/translation/service/apachetika/ApacheTikaLangDetectService.java @@ -38,6 +38,20 @@ public List detectLang(List texts, String langHint) throws Langu if (texts.isEmpty()) { return new ArrayList<>(); } + + /* + * this code can be used for testing the lang hint, but the setPriors map cannot be sent empty or null + */ +// try { +// Map languageProbabilities = new HashMap(); +// if(! StringUtils.isBlank(langHint)) { +// languageProbabilities.put(langHint, (float) 1.0); +// } +// this.detector.setPriors(languageProbabilities); +// } catch (IOException e) { +// throw new LanguageDetectionException( +// "Invalid setting of the language hint for the Apache-Tika service!", -1, e); +// } List detectedLangs = new ArrayList(); for(String text : texts) {