Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion datasource-provider/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.9.1</version>
<version>2.17.1</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.plugin</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Valence_ANEW=Affective Norms for English Words Valence
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public List<ComplexityIndex> 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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -27,7 +30,7 @@
public class WordValences {

private static final Map<Lang, Map<String, Map<String, Double>>> WORD_VALENCE_MAP = new EnumMap<>(Lang.class);
private static final Map<Lang, List<String>> VALENCES_FOR_LANG = new EnumMap<>(Lang.class);
private static final Map<Lang, Map<String, String>> 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<Lang> SUPPORTED_LANGUAGES = Arrays.asList(Lang.en, Lang.fr, Lang.es);
Expand All @@ -44,9 +47,9 @@ private static void initLang(Lang lang) {
header = in.readLine();
}
String[] splitHeader = header.split(";");
ArrayList<String> valences = new ArrayList<>();
Map<String, String> 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;
Expand Down Expand Up @@ -74,7 +77,7 @@ public static Double getValenceForWord(Word word, String valence) {
.getOrDefault(valence, 0.);
}

public static List<String> getValences(Lang lang) {
public static Map<String, String> getValences(Lang lang) {
if (!VALENCES_FOR_LANG.containsKey(lang)) {
initLang(lang);
}
Expand Down