Skip to content

Commit

Permalink
improved code smells
Browse files Browse the repository at this point in the history
  • Loading branch information
SrdjanStevanetic committed Nov 29, 2023
1 parent 1c27732 commit 720a6c7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,8 @@ public List<String> detectLang(List<String> texts, String langHint) throws Langu
if (texts.isEmpty()) {
return Collections.emptyList();
}

/*
* this code can be used for testing the lang hint, but the setPriors map cannot be sent empty or null,
* and once it is set, it stays for the next call as well, so to empty it, the detector would probably
* need to be recreated
*/
// try {
// Map<String, Float> languageProbabilities = new HashMap<String, Float>();
// 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<String> detectedLangs = new ArrayList<String>();
List<String> detectedLangs = new ArrayList<>();
List<LanguageResult> tikaLanguages=null;
for(String text : texts) {
//returns all tika languages sorted by score
Expand Down Expand Up @@ -92,8 +76,7 @@ private String chooseDetectedLang(List<LanguageResult> tikaLanguages, String lan
detectedLang=langHint;
break;
}
}
else {
} else {
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package eu.europeana.api.translation.tests.web;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
Expand Down Expand Up @@ -87,7 +88,7 @@ void langDetectionApacheTika() throws Exception {
JSONArray langs = json.getJSONArray(TranslationAppConstants.LANGS);
assertTrue(langs.length()==3 && "hr".equals(langs.getString(0)) && "de".equals(langs.getString(1)) && "en".equals(langs.getString(2)));
String serviceFieldValue = json.getString(TranslationAppConstants.SERVICE);
assertTrue("APACHE-TIKA".equals(serviceFieldValue));
assertEquals("APACHE-TIKA", serviceFieldValue);
}

@Test
Expand Down

0 comments on commit 720a6c7

Please sign in to comment.