File JLanguageTool-1.2-package-dicts-separately.diff of Package libreoffice-languagetool
--- build.xml
+++ build.xml
@@ -443,105 +443,56 @@
<copy file="${resource.dir}/segment.srx" todir="${dist.dir}/resource" />
<copy file="${resource.dir}/en/tagset.txt" todir="${dist.dir}/resource/en" />
-<copy file="${resource.dir}/en/english.dict" todir="${dist.dir}/resource/en" />
-<copy file="${resource.dir}/en/english.info" todir="${dist.dir}/resource/en" />
-<copy file="${resource.dir}/en/english_synth.dict" todir="${dist.dir}/resource/en" />
-<copy file="${resource.dir}/en/english_synth.info" todir="${dist.dir}/resource/en" />
<copy file="${resource.dir}/en/english_tags.txt" todir="${dist.dir}/resource/en" />
<copy file="${resource.dir}/en/disambiguation.xml" todir="${dist.dir}/resource/en" />
<copy file="${resource.dir}/en/compounds.txt" todir="${dist.dir}/resource/en" />
<copy file="${resource.dir}/eo/etikedoj.txt" todir="${dist.dir}/resource/eo" />
-<copy file="${resource.dir}/it/italian.dict" todir="${dist.dir}/resource/it" />
-<copy file="${resource.dir}/it/italian.info" todir="${dist.dir}/resource/it" />
<copy file="${resource.dir}/it/readme-morph-it.txt" todir="${dist.dir}/resource/it" />
-<copy file="${resource.dir}/fr/french.dict" todir="${dist.dir}/resource/fr" />
-<copy file="${resource.dir}/fr/french.info" todir="${dist.dir}/resource/fr" />
<copy file="${resource.dir}/fr/README_lexique.txt" todir="${dist.dir}/resource/fr" />
<copy file="${resource.dir}/fr/tagset.LT.txt" todir="${dist.dir}/resource/fr" />
<copy file="${resource.dir}/fr/disambiguation.xml" todir="${dist.dir}/resource/fr" />
-<copy file="${resource.dir}/gl/galician.dict" todir="${dist.dir}/resource/gl" />
-<copy file="${resource.dir}/gl/galician.info" todir="${dist.dir}/resource/gl" />
<copy file="${resource.dir}/gl/README" todir="${dist.dir}/resource/gl" />
-<copy file="${resource.dir}/es/spanish.dict" todir="${dist.dir}/resource/es" />
-<copy file="${resource.dir}/es/spanish.info" todir="${dist.dir}/resource/es" />
<copy file="${resource.dir}/es/etiquetas-eagles.txt" todir="${dist.dir}/resource/es" />
-<copy file="${resource.dir}/es/spanish_synth.dict" todir="${dist.dir}/resource/es" />
-<copy file="${resource.dir}/es/spanish_synth.info" todir="${dist.dir}/resource/es" />
<copy file="${resource.dir}/es/spanish_tags.txt" todir="${dist.dir}/resource/es" />
<copy file="${resource.dir}/es/README" todir="${dist.dir}/resource/es" />
<copy file="${resource.dir}/da/danish_tags.txt" todir="${dist.dir}/resource/da" />
-<copy file="${resource.dir}/da/danish.dict" todir="${dist.dir}/resource/da" />
-<copy file="${resource.dir}/da/danish.info" todir="${dist.dir}/resource/da" />
-<copy file="${resource.dir}/de/german.dict" todir="${dist.dir}/resource/de" />
-<copy file="${resource.dir}/de/german.info" todir="${dist.dir}/resource/de" />
<copy file="${resource.dir}/de/compounds.txt" todir="${dist.dir}/resource/de" />
<copy file="${resource.dir}/de/added.txt" todir="${dist.dir}/resource/de" />
<copy file="${resource.dir}/de/tagset.txt" todir="${dist.dir}/resource/de" />
-<copy file="${resource.dir}/pl/polish.dict" todir="${dist.dir}/resource/pl" />
-<copy file="${resource.dir}/pl/polish.info" todir="${dist.dir}/resource/pl" />
-<copy file="${resource.dir}/pl/polish_synth.dict" todir="${dist.dir}/resource/pl" />
-<copy file="${resource.dir}/pl/polish_synth.info" todir="${dist.dir}/resource/pl" />
<copy file="${resource.dir}/pl/polish_tags.txt" todir="${dist.dir}/resource/pl" />
<copy file="${resource.dir}/pl/compounds.txt" todir="${dist.dir}/resource/pl" />
<copy file="${resource.dir}/pl/multiwords.txt" todir="${dist.dir}/resource/pl" />
<copy file="${resource.dir}/pl/disambiguation.xml" todir="${dist.dir}/resource/pl" />
-<copy file="${resource.dir}/nl/dutch.dict" todir="${dist.dir}/resource/nl" />
-<copy file="${resource.dir}/nl/dutch.info" todir="${dist.dir}/resource/nl" />
-<copy file="${resource.dir}/nl/dutch_synth.dict" todir="${dist.dir}/resource/nl" />
-<copy file="${resource.dir}/nl/dutch_synth.info" todir="${dist.dir}/resource/nl" />
<copy file="${resource.dir}/nl/dutch_tags.txt" todir="${dist.dir}/resource/nl" />
<copy file="${resource.dir}/nl/disambiguation.xml" todir="${dist.dir}/resource/nl" />
-<copy file="${resource.dir}/sv/swedish.info" todir="${dist.dir}/resource/sv" />
-<copy file="${resource.dir}/sv/swedish.dict" todir="${dist.dir}/resource/sv" />
<copy file="${resource.dir}/sv/compounds.txt" todir="${dist.dir}/resource/sv" />
-<copy file="${resource.dir}/uk/ukrainian.dict" todir="${dist.dir}/resource/uk" />
-
-<copy file="${resource.dir}/ru/russian.dict" todir="${dist.dir}/resource/ru" />
-<copy file="${resource.dir}/ru/russian.info" todir="${dist.dir}/resource/ru" />
<copy file="${resource.dir}/ru/russian_tags.txt" todir="${dist.dir}/resource/ru" />
-<copy file="${resource.dir}/ru/russian_synth.dict" todir="${dist.dir}/resource/ru" />
-<copy file="${resource.dir}/ru/russian_synth.info" todir="${dist.dir}/resource/ru" />
<copy file="${resource.dir}/ru/tags_russian.txt" todir="${dist.dir}/resource/ru" />
<copy file="${resource.dir}/ru/compounds_ru.txt" todir="${dist.dir}/resource/ru" />
<copy file="${resource.dir}/ru/disambiguation.xml" todir="${dist.dir}/resource/ru" />
-<copy file="${resource.dir}/ro/romanian.dict" todir="${dist.dir}/resource/ro" />
-<copy file="${resource.dir}/ro/romanian.info" todir="${dist.dir}/resource/ro" />
-<copy file="${resource.dir}/ro/romanian_synth.dict" todir="${dist.dir}/resource/ro" />
-<copy file="${resource.dir}/ro/romanian_synth.info" todir="${dist.dir}/resource/ro" />
<copy file="${resource.dir}/ro/romanian_tags.txt" todir="${dist.dir}/resource/ro" />
<copy file="${resource.dir}/ro/disambiguation.xml" todir="${dist.dir}/resource/ro" />
-<copy file="${resource.dir}/sk/slovak.dict" todir="${dist.dir}/resource/sk" />
-<copy file="${resource.dir}/sk/slovak.info" todir="${dist.dir}/resource/sk" />
<copy file="${resource.dir}/sk/compounds.txt" todir="${dist.dir}/resource/sk" />
<copy file="${resource.dir}/sk/README" todir="${dist.dir}/resource/sk" />
-<copy file="${resource.dir}/sk/slovak_synth.dict" todir="${dist.dir}/resource/sk" />
-<copy file="${resource.dir}/sk/slovak_synth.info" todir="${dist.dir}/resource/sk" />
<copy file="${resource.dir}/sk/slovak_tags.txt" todir="${dist.dir}/resource/sk" />
-<copy file="${resource.dir}/ml/malayalam.dict" todir="${dist.dir}/resource/ml" />
-<copy file="${resource.dir}/ml/malayalam.info" todir="${dist.dir}/resource/ml" />
-
<copy file="${resource.dir}/ca/catalan_synth.dict" todir="${dist.dir}/resource/ca" />
<copy file="${resource.dir}/ca/catalan_tags.txt" todir="${dist.dir}/resource/ca" />
-<copy file="${resource.dir}/ca/catalan.dict" todir="${dist.dir}/resource/ca" />
-<copy file="${resource.dir}/ca/catalan.info" todir="${dist.dir}/resource/ca" />
<copy file="${resource.dir}/ca/README" todir="${dist.dir}/resource/ca" />
-<copy file="${resource.dir}/xx/dummy.dict" tofile="${dist.dir}/resource/cs/czech.dict" />
-
<!-- prepare properties file automatically -->
<javac encoding="${encoding}" srcdir="${src.dir}/dev" includes="de/danielnaber/languagetool/dev/PrintLocales.java" destdir="${build.classes}" target="${target}" debug="${debug}">
</javac>
--- src/java/de/danielnaber/languagetool/openoffice/Main.java
+++ src/java/de/danielnaber/languagetool/openoffice/Main.java
@@ -23,6 +23,7 @@
*
* @author Marcin MiĆkowski
*/
+import java.io.IOException;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
@@ -476,9 +477,18 @@
* The Locale to check.
*/
public final boolean hasLocale(final Locale locale) {
+ List<String> dummyList = new ArrayList<String>();
try {
for (final Language element : Language.LANGUAGES) {
- if (element.getShortName().equals(locale.Language)) {
+ // FIXME: dirty hack that checks whether the dictionary is really installed
+ // it is better to have dictionaries in optional packages
+ boolean dictionaryExists = true;
+ try {
+ element.getTagger().tag(dummyList);
+ } catch (IOException e) {
+ dictionaryExists = false;
+ }
+ if (dictionaryExists && element.getShortName().equals(locale.Language)) {
return true;
}
}
--- src/java/de/danielnaber/languagetool/tagging/BaseTagger.java
+++ src/java/de/danielnaber/languagetool/tagging/BaseTagger.java
@@ -61,6 +61,9 @@
// caching IStemmer instance - lazy init
if (morfologik == null) {
final URL url = this.getClass().getResource(getFileName());
+ if (url == null) {
+ throw new IOException("Did not detect the dictonary file");
+ }
morfologik = new DictionaryLookup(Dictionary.read(url));
}
--- src/java/de/danielnaber/languagetool/tagging/cs/CzechTagger.java
+++ src/java/de/danielnaber/languagetool/tagging/cs/CzechTagger.java
@@ -60,6 +60,9 @@
// caching Lametyzator instance - lazy init
if (morfologik == null) {
final URL url = JLanguageTool.getDataBroker().getFromResourceDirAsUrl(RESOURCE_FILENAME);
+ if (url == null) {
+ throw new IOException("Did not detect the dictonary file");
+ }
morfologik = new DictionaryLookup(Dictionary.read(url));
}
--- src/java/de/danielnaber/languagetool/tagging/de/GermanTagger.java
+++ src/java/de/danielnaber/languagetool/tagging/de/GermanTagger.java
@@ -74,6 +74,9 @@
// caching Lametyzator instance - lazy init
if (morfologik == null) {
final URL url = JLanguageTool.getDataBroker().getFromResourceDirAsUrl(DICT_FILENAME);
+ if (url == null) {
+ throw new IOException("Did not detect the dictonary file");
+ }
morfologik = new DictionaryLookup(Dictionary.read(url));
}
if (manualTagger == null) {
--- src/java/de/danielnaber/languagetool/tagging/pl/PolishTagger.java
+++ src/java/de/danielnaber/languagetool/tagging/pl/PolishTagger.java
@@ -61,6 +61,9 @@
// caching Lametyzator instance - lazy init
if (morfologik == null) {
final URL url = JLanguageTool.getDataBroker().getFromResourceDirAsUrl(RESOURCE_FILENAME);
+ if (url == null) {
+ throw new IOException("Did not detect the dictonary file");
+ }
morfologik = new DictionaryLookup(Dictionary.read(url));
}
--- src/java/de/danielnaber/languagetool/tagging/ro/RomanianTagger.java
+++ src/java/de/danielnaber/languagetool/tagging/ro/RomanianTagger.java
@@ -71,6 +71,9 @@
// caching Lametyzator instance - lazy init
if (morfologik == null) {
final URL url = JLanguageTool.getDataBroker().getFromResourceDirAsUrl(RESOURCE_FILENAME);
+ if (url == null) {
+ throw new IOException("Did not detect the dictonary file");
+ }
morfologik = new DictionaryLookup(Dictionary.read(url));
}
--- src/java/de/danielnaber/languagetool/tagging/uk/UkrainianMyspellTagger.java
+++ src/java/de/danielnaber/languagetool/tagging/uk/UkrainianMyspellTagger.java
@@ -62,6 +62,9 @@
if (wordsToPos == null) {
wordsToPos = new HashMap<String, String[]>();
final InputStream resourceFile = JLanguageTool.getDataBroker().getFromResourceDirAsStream(RESOURCE_FILENAME);
+ if (resourceFile == null) {
+ throw new IOException("Did not detect the dictonary file");
+ }
// System.err.println("reading dict: " + resourceFile);
final BufferedReader input = new BufferedReader(new InputStreamReader(