diff --git a/datasource-provider/pom.xml b/datasource-provider/pom.xml index 3b9ae275..110dd38e 100644 --- a/datasource-provider/pom.xml +++ b/datasource-provider/pom.xml @@ -57,7 +57,7 @@ org.apache.logging.log4j log4j-core - 2.9.1 + 2.17.1 org.elasticsearch.plugin diff --git a/pom.xml b/pom.xml index 8619c9d3..7d4cbd45 100644 --- a/pom.xml +++ b/pom.xml @@ -43,7 +43,7 @@ 1.9.13 1.7.25 - 2.11.0 + 2.17.1 2.11.0 4.12 diff --git a/textual-complexity/src/main/config/sentiment_valences_descriptions_en.properties b/textual-complexity/src/main/config/sentiment_valences_descriptions_en.properties new file mode 100644 index 00000000..75e0bfd8 --- /dev/null +++ b/textual-complexity/src/main/config/sentiment_valences_descriptions_en.properties @@ -0,0 +1 @@ +Valence_ANEW=Affective Norms for English Words Valence diff --git a/textual-complexity/src/main/java/com/readerbench/textualcomplexity/wordLists/WordListsIndicesFactory.java b/textual-complexity/src/main/java/com/readerbench/textualcomplexity/wordLists/WordListsIndicesFactory.java index 3818906c..1a833d8d 100644 --- a/textual-complexity/src/main/java/com/readerbench/textualcomplexity/wordLists/WordListsIndicesFactory.java +++ b/textual-complexity/src/main/java/com/readerbench/textualcomplexity/wordLists/WordListsIndicesFactory.java @@ -27,7 +27,7 @@ public List build(Lang lang) { if (!WordValences.SUPPORTED_LANGUAGES.contains(lang)) { return result; } - WordValences.getValences(lang).stream() + WordValences.getValences(lang).keySet().stream() .forEach(sv -> { result.add(new AvgWordsInList( ComplexityIndicesEnum.AVG_WORDS_IN_LIST_PER_DOC, diff --git a/textual-complexity/src/main/java/com/readerbench/textualcomplexity/wordLists/WordValences.java b/textual-complexity/src/main/java/com/readerbench/textualcomplexity/wordLists/WordValences.java index ce7b947e..75ffbf2c 100644 --- a/textual-complexity/src/main/java/com/readerbench/textualcomplexity/wordLists/WordValences.java +++ b/textual-complexity/src/main/java/com/readerbench/textualcomplexity/wordLists/WordValences.java @@ -5,9 +5,11 @@ */ package com.readerbench.textualcomplexity.wordLists; +import com.readerbench.coreservices.data.AbstractDocument; import com.readerbench.coreservices.data.Word; import com.readerbench.datasourceprovider.commons.ReadProperty; import com.readerbench.datasourceprovider.pojo.Lang; +import com.readerbench.textualcomplexity.ComplexityIndex; import java.io.*; import java.util.ArrayList; @@ -17,6 +19,7 @@ import java.util.List; import java.util.Map; import java.util.Properties; +import java.util.ResourceBundle; import java.util.logging.Level; import java.util.logging.Logger; @@ -27,7 +30,7 @@ public class WordValences { private static final Map>> WORD_VALENCE_MAP = new EnumMap<>(Lang.class); - private static final Map> VALENCES_FOR_LANG = new EnumMap<>(Lang.class); + private static final Map> VALENCES_FOR_LANG = new EnumMap<>(Lang.class); private static final Properties PROPERTIES = ReadProperty.getProperties("textual_complexity_paths.properties"); private static final String PROPERTY_VALENCES_NAME = "VALENCES_%s_PATH"; public static final List SUPPORTED_LANGUAGES = Arrays.asList(Lang.en, Lang.fr, Lang.es); @@ -44,9 +47,9 @@ private static void initLang(Lang lang) { header = in.readLine(); } String[] splitHeader = header.split(";"); - ArrayList valences = new ArrayList<>(); + Map valences = new HashMap<>(); for (int i = 1; i < splitHeader.length; i++) { - valences.add(splitHeader[i]); + valences.put(splitHeader[i], ResourceBundle.getBundle("sentiment_valences_descriptions", lang.getLocale()).getString(splitHeader[i])); } VALENCES_FOR_LANG.put(lang, valences); String line; @@ -74,7 +77,7 @@ public static Double getValenceForWord(Word word, String valence) { .getOrDefault(valence, 0.); } - public static List getValences(Lang lang) { + public static Map getValences(Lang lang) { if (!VALENCES_FOR_LANG.containsKey(lang)) { initLang(lang); }