From 40d8086bf7c8bab23e24b79fcac52990d586d2a9 Mon Sep 17 00:00:00 2001 From: reger Date: Sun, 9 Sep 2012 06:15:25 +0200 Subject: [PATCH] keep input order of translation entries within one file section. Allowing on translation conflicts (translaton of words contained in other sentence) to put shorter key at the end of the translation list. --- source/de/anomic/data/Translator.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/de/anomic/data/Translator.java b/source/de/anomic/data/Translator.java index 23135c23e..22b62f9b9 100644 --- a/source/de/anomic/data/Translator.java +++ b/source/de/anomic/data/Translator.java @@ -50,6 +50,7 @@ import net.yacy.kelondro.logging.Log; import net.yacy.kelondro.util.FileUtils; import net.yacy.kelondro.util.Formatter; import de.anomic.server.serverSwitch; +import java.util.*; /** * Wordlist based translator @@ -79,12 +80,14 @@ public class Translator { /** * Load multiple translationLists from one File. Each List starts with #File: relative/path/to/file + * (within each file section translation is done in order of the language file entries, on conflicts + * put the shorter key to the end of the list) * @param translationFile the File, which contains the Lists * @return a HashMap, which contains for each File a HashMap with translations. */ public static Map> loadTranslationsLists(final File translationFile){ final Map> lists = new HashMap>(); //list of translationLists for different files. - Map translationList = new HashMap(); //current Translation Table + Map translationList = new LinkedHashMap(); //current Translation Table (maintaining input order) final List list = FileUtils.getListArray(translationFile); String forFile = ""; @@ -108,7 +111,7 @@ public class Translator { if (lists.containsKey(forFile)) { translationList = lists.get(forFile); } else { - translationList = new HashMap(); + translationList = new LinkedHashMap(); } } }