package com.hughes.android.dictionary.engine;
+import com.hughes.android.dictionary.DictionaryInfo;
+import com.hughes.android.dictionary.DictionaryInfo.IndexInfo;
+import com.hughes.util.CollectionUtil;
+
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Collections;
import java.util.List;
-import com.hughes.android.dictionary.DictionaryInfo;
-import com.hughes.android.dictionary.parser.wiktionary.WiktionaryLangs;
-
public class CheckDictionariesMain {
- static final String BASE_URL = "http://quickdic-dictionary.googlecode.com/files/";
- static final String VERSION_CODE = "v005";
+ static final String BASE_URL = "http://github.com/rdoeffinger/Dictionary/releases/download/v0.2-dictionaries/";
+ static final String VERSION_CODE_OLD = "v006";
+ static final String VERSION_CODE = "v007";
public static void main(String[] args) throws IOException {
final File dictDir = new File(DictionaryBuilderMain.OUTPUTS);
final DictionaryInfo dictionaryInfo = dict.getDictionaryInfo();
+ String version_code = VERSION_CODE;
+ File zipFile = new File(dictFile.getPath() + "." + version_code + ".zip");
+ if (!zipFile.canRead()) {
+ version_code = VERSION_CODE_OLD;
+ zipFile = new File(dictFile.getPath() + "." + version_code + ".zip");
+ }
dictionaryInfo.uncompressedFilename = dictFile.getName();
- dictionaryInfo.downloadUrl = BASE_URL + dictFile.getName() + "." + VERSION_CODE + ".zip";
+ dictionaryInfo.downloadUrl = BASE_URL + dictFile.getName() + "." + version_code + ".zip";
// TODO: zip it right here....
dictionaryInfo.uncompressedBytes = dictFile.length();
- final File zipFile = new File(dictFile.getPath() + "." + VERSION_CODE + ".zip");
dictionaryInfo.zipBytes = zipFile.canRead() ? zipFile.length() : -1;
// Print it.
// Find the stats.
System.out.println("Stats...");
- final String lang1 = WiktionaryLangs.isoCodeToWikiName.get(dictionaryInfo.indexInfos.get(0).shortName);
- final String lang2 = WiktionaryLangs.isoCodeToWikiName.get(dictionaryInfo.indexInfos.get(1).shortName);
- dictNames.add(String.format("%s-%s\n", lang1, lang2));
+ final List<String> indexNames = new ArrayList<String>();
+ for (final IndexInfo indexInfo : dictionaryInfo.indexInfos) {
+ indexNames.add(indexInfo.shortName);
+ }
+ dictNames.add(CollectionUtil.join(indexNames, "-") + "\n");
final String row = dictionaryInfo.append(new StringBuilder()).toString();
if (!zipFile.canRead()) {
System.err.println("Couldn't read zipfile: " + zipFile);
}
Collections.sort(dictNames);
- System.out.println(dictNames.toString().replaceAll(",", " *"));
+ System.out.println(dictNames.toString().replace(",", " *"));
dictionaryInfoOut.close();
}