diff --git a/src/main/java/io/github/eb4j/ebview/dictionary/DictionariesManager.java b/src/main/java/io/github/eb4j/ebview/dictionary/DictionariesManager.java index 638fde1..31b38af 100644 --- a/src/main/java/io/github/eb4j/ebview/dictionary/DictionariesManager.java +++ b/src/main/java/io/github/eb4j/ebview/dictionary/DictionariesManager.java @@ -51,7 +51,7 @@ public void closeDict(final IDictionary dict) { } public List getDictionaryNames() { - return Collections.unmodifiableList(dictionaries.stream().map(IDictionary::getDictionaryName).collect(Collectors.toList())); + return dictionaries.stream().map(IDictionary::getDictionaryName).collect(Collectors.toUnmodifiableList()); } /** diff --git a/src/main/java/io/github/eb4j/ebview/dictionary/lingvo/LingvoDSLDictionary.java b/src/main/java/io/github/eb4j/ebview/dictionary/lingvo/LingvoDSLDictionary.java index 8a88075..b8541e1 100644 --- a/src/main/java/io/github/eb4j/ebview/dictionary/lingvo/LingvoDSLDictionary.java +++ b/src/main/java/io/github/eb4j/ebview/dictionary/lingvo/LingvoDSLDictionary.java @@ -34,7 +34,7 @@ public class LingvoDSLDictionary implements IDictionary { protected final DictionaryData data; - + private final String dictionaryDir; private final String bookName; @@ -47,6 +47,7 @@ public LingvoDSLDictionary(final File file) throws Exception { bookName = fileName.substring(0, fileName.length() - 4); } readDslFile(file); + dictionaryDir = file.getParentFile().getAbsolutePath(); } @SuppressWarnings("avoidinlineconditionals") @@ -95,13 +96,13 @@ public String getDictionaryName() { @Override public List readArticles(final String word) { - return data.lookUp(word).stream().map(e -> new DictionaryEntry(e.getKey(), e.getValue(), bookName)) + return data.lookUp(word).stream().map(e -> new DictionaryEntry(e.getKey(), e.getValue().replaceAll("@dir@", dictionaryDir), bookName)) .collect(Collectors.toList()); } @Override public List readArticlesPredictive(final String word) { - return data.lookUpPredictive(word).stream().map(e -> new DictionaryEntry(e.getKey(), e.getValue(), bookName)) + return data.lookUpPredictive(word).stream().map(e -> new DictionaryEntry(e.getKey(), e.getValue().replaceAll("@dir@", dictionaryDir), bookName)) .collect(Collectors.toList()); } @@ -175,8 +176,11 @@ static String replaceTag(final String line) { reList.add(new RE("\\[/preview\\]", "")); reList.add(new RE("\\[ref\\]", "")); reList.add(new RE("\\[/ref\\]", "")); - reList.add(new RE("\\[s\\]", "")); - reList.add(new RE("\\[/s\\]", "")); + reList.add(new RE("\\[s\\](.+?\\.wav)\\[/s\\]", "SOUND: $1")); + reList.add(new RE("\\[s\\](.+?\\.jpg)\\[/s\\]", "")); + reList.add(new RE("\\[s\\](.+?\\.bmp)\\[/s\\]", "")); + reList.add(new RE("\\[video\\](.+?)\\[/video\\]", "VIDEO: $1")); + reList.add(new RE("\\[s\\](.+?)\\[/s\\]", "UNSUPPORTED MEDIA: $1")); reList.add(new RE("\\[sub\\](.+?)\\[/sub\\]", "$1")); reList.add(new RE("\\[sup\\](.+?)\\[/sup\\]", "$1")); reList.add(new RE("\\[trn1\\]", "")); @@ -189,8 +193,6 @@ static String replaceTag(final String line) { reList.add(new RE("\\[u\\](.+?)\\[/u\\]", "$1")); reList.add(new RE("\\[url\\](.+?)\\[/url\\]", "$1")); - reList.add(new RE("\\[video\\]", "")); - reList.add(new RE("\\[/video\\]", "")); // The following line tries to replace a letter surrounded by ['][/'] tags (indicating stress) // with a red letter (the default behavior in Lingvo). reList.add(new RE("\\['\\].\\[/'\\]", "$1"));