]> gitweb.fperrin.net Git - DictionaryPC.git/blobdiff - src/com/hughes/android/dictionary/engine/DictionaryBuilderTest.java
Build fr_de dictionary from enwiktionary, yeah!
[DictionaryPC.git] / src / com / hughes / android / dictionary / engine / DictionaryBuilderTest.java
index 7f1bebaa06aed5f62bb8ee4ce9c91ba3e81943e8..ffd1d7eb696da93358df329353a3e1ac04150ed2 100644 (file)
@@ -20,6 +20,7 @@ import java.io.IOException;
 import java.io.PrintStream;
 import java.io.RandomAccessFile;
 
+import com.hughes.android.dictionary.parser.wiktionary.EnTranslationToTranslationParser;
 import com.hughes.util.FileUtil;
 
 import junit.framework.TestCase;
@@ -32,6 +33,37 @@ public class DictionaryBuilderTest extends TestCase {
   public static final String GOLDENS = "testdata/goldens/";
 
   public static final String TEST_OUTPUTS = "testdata/outputs/";
+
+  
+  public void testWiktionary_en_de2fr() throws Exception {
+    wiktionaryTestWithEnTrans2Trans("wiktionary.de_fr.quickdic", "DE", "FR");
+  }
+
+  public void wiktionaryTestWithEnTrans2Trans(final String name, final String lang1,
+      final String lang2) throws Exception {
+    final File result = new File(TEST_OUTPUTS + name);
+    System.out.println("Writing to: " + result);
+    DictionaryBuilder.main(new String[] {
+        "--dictOut=" + result.getAbsolutePath(),
+        "--lang1=" + lang1,
+        "--lang2=" + lang2,
+        "--lang1Stoplist=" + STOPLISTS + "empty.txt",
+        "--lang2Stoplist=" + STOPLISTS + "empty.txt",
+        "--dictInfo=SomeWikiDataTrans2Trans",
+
+        "--input4=" + WIKISPLIT + "EN.data",
+        "--input4Name=" + name,
+        "--input4Format=" + EnTranslationToTranslationParser.NAME,
+        "--input4LangPattern1=" + lang1,
+        "--input4LangPattern2=" + lang2,
+        "--input4PageLimit=1000",
+
+        "--print=" + result.getPath() + ".text",
+    });
+    
+    checkGolden(name, result); 
+  }
+
   
   public void testWiktionary_IT_EN() throws Exception {
     wiktionaryTestWithLangToEn("wiktionary.it_en.quickdic", "IT", "it.txt",
@@ -80,11 +112,19 @@ public class DictionaryBuilderTest extends TestCase {
         "DE.data", "enwiktionary.german", "German", "it");
   }
 
+  // Thai
+  public void testWiktionary_TH_TH() throws Exception {
+    wiktionaryTestWithLangToEn("wiktionary.th_th.quickdic", "TH", "empty.txt",
+        // These missing "e" prevents a complete match, forcing the name to be printed.
+        "TH.data", "enwiktionary.thai", "Thai", "th");
+  }
+
   public void wiktionaryTestWithLangToEn(final String name, final String lang1,
       final String stoplist, final String data, final String dictName,
       final String langPattern, final String langCode) throws Exception {
     final File result = new File(TEST_OUTPUTS + name);
     System.out.println("Writing to: " + result);
+    final String type = data.equals("EN.data") ? "EnToTranslation" : "EnForeign";
     DictionaryBuilder.main(new String[] {
         "--dictOut=" + result.getAbsolutePath(),
         "--lang1=" + lang1,
@@ -96,6 +136,7 @@ public class DictionaryBuilderTest extends TestCase {
         "--input4=" + WIKISPLIT + data,
         "--input4Name=" + dictName,
         "--input4Format=enwiktionary",
+        "--input4WiktionaryType=" + type,
         "--input4LangPattern=" + langPattern,
         "--input4LangCodePattern=" + langCode,
         "--input4EnIndex=2",