1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
try {
URL zipUrl = Synonyms.class.getResource("thesaurus_" + lang + ".ocid");
if (zipUrl == null) {
trace("perhaps there is no zipped synonyms file");
return mot;
}
trace("zipUrl=" + zipUrl.toString());
ZipFile zip = new ZipFile(new File(zipUrl.getFile()));
ZipEntry entry = zip.getEntry("thesaurus_" + lang + ".dic");
if (entry == null) {
trace("no entry for synonyms");
return mot;
}
InputStream input = zip.getInputStream(entry);
try (BufferedReader br = new BufferedReader(
new InputStreamReader(input, "UTF-8"))) {
String line = br.readLine();
while (line != null) {
if (!line.startsWith("#")) {
mot = getWord(line, word);
if (mot != null) {
return mot;
}
}
line = br.readLine();
}
br.close();
}
} catch (IOException ex) {
err("Exception", ex);
} |