diff options
author | Bjørn Christian Seime <bjorncs@yahooinc.com> | 2023-08-31 16:22:27 +0200 |
---|---|---|
committer | Bjørn Christian Seime <bjorncs@yahooinc.com> | 2023-08-31 16:22:27 +0200 |
commit | a63aa94a37e08573166e75d21157e2277bf1082f (patch) | |
tree | a81f1a26ed2e8eaa790599a88ced150adcedbed5 /opennlp-linguistics | |
parent | 97770eb6e8e75aa20b0ce6c08372346e91b90f66 (diff) |
Allow version and surpress deprecation warnings
Diffstat (limited to 'opennlp-linguistics')
2 files changed, 4 insertions, 2 deletions
diff --git a/opennlp-linguistics/src/main/java/com/yahoo/language/opennlp/DefaultLanguageDetectorContextGenerator.java b/opennlp-linguistics/src/main/java/com/yahoo/language/opennlp/DefaultLanguageDetectorContextGenerator.java index 27c23d8d3e6..5893429f5d0 100644 --- a/opennlp-linguistics/src/main/java/com/yahoo/language/opennlp/DefaultLanguageDetectorContextGenerator.java +++ b/opennlp-linguistics/src/main/java/com/yahoo/language/opennlp/DefaultLanguageDetectorContextGenerator.java @@ -19,14 +19,15 @@ public class DefaultLanguageDetectorContextGenerator extends opennlp.tools.langd } @Override - public String[] getContext(CharSequence document) { + @SuppressWarnings("unchecked") + public <T extends CharSequence> T[] getContext(CharSequence document) { int[] normalized = normalizer.normalize(document).codePoints().map(Character::toLowerCase).toArray(); Set<String> grams = new HashSet<>(); for (int i = 0; i < normalized.length; i++) for (int j = minLength; j <= maxLength && i + j < normalized.length; j++) grams.add(new String(normalized, i, j)); - return grams.toArray(new String[grams.size()]); + return (T[])grams.toArray(new String[grams.size()]); } } diff --git a/opennlp-linguistics/src/main/java/com/yahoo/language/opennlp/OpenNlpDetector.java b/opennlp-linguistics/src/main/java/com/yahoo/language/opennlp/OpenNlpDetector.java index d7a7d3a4744..b89e93c9d24 100644 --- a/opennlp-linguistics/src/main/java/com/yahoo/language/opennlp/OpenNlpDetector.java +++ b/opennlp-linguistics/src/main/java/com/yahoo/language/opennlp/OpenNlpDetector.java @@ -83,6 +83,7 @@ class OpenNlpDetector implements Detector { return new Detection(detectLanguage(input), UTF_8.name(), false); } + @SuppressWarnings("removal") private Language detectLanguage(String input) { var prediction = detector.probingPredictLanguages(input, config).getLanguages()[0]; var result = prediction.getConfidence() > 0.02 ? languagesByISO3.get(prediction.getLang()) : null; |