public void testOneDictionary() throws Exception { Path tmp = LuceneTestCase.createTempDir(); String toTest = "zu_ZA.zip"; for (int i = 0; i < tests.length; i++) { if (tests[i].equals(toTest)) { Path f = DICTIONARY_HOME.resolve(tests[i]); assert Files.exists(f); IOUtils.rm(tmp); Files.createDirectory(tmp); try (InputStream in = Files.newInputStream(f)) { TestUtil.unzip(in, tmp); Path dicEntry = tmp.resolve(tests[i + 1]); Path affEntry = tmp.resolve(tests[i + 2]); try (InputStream dictionary = Files.newInputStream(dicEntry); InputStream affix = Files.newInputStream(affEntry); Directory tempDir = getDirectory()) { new Dictionary(tempDir, "dictionary", affix, dictionary); } } } } }
public void test() throws Exception { Path tmp = LuceneTestCase.createTempDir(); for (int i = 0; i < tests.length; i += 3) { Path f = DICTIONARY_HOME.resolve(tests[i]); assert Files.exists(f); IOUtils.rm(tmp); Files.createDirectory(tmp); try (InputStream in = Files.newInputStream(f); Directory tempDir = getDirectory()) { TestUtil.unzip(in, tmp); Path dicEntry = tmp.resolve(tests[i + 1]); Path affEntry = tmp.resolve(tests[i + 2]); try (InputStream dictionary = Files.newInputStream(dicEntry); InputStream affix = Files.newInputStream(affEntry)) { Dictionary dic = new Dictionary(tempDir, "dictionary", affix, dictionary); System.out.println( tests[i] + "\t" + RamUsageTester.humanSizeOf(dic) + "\t(" + "words=" + RamUsageTester.humanSizeOf(dic.words) + ", " + "flags=" + RamUsageTester.humanSizeOf(dic.flagLookup) + ", " + "strips=" + RamUsageTester.humanSizeOf(dic.stripData) + ", " + "conditions=" + RamUsageTester.humanSizeOf(dic.patterns) + ", " + "affixData=" + RamUsageTester.humanSizeOf(dic.affixData) + ", " + "prefixes=" + RamUsageTester.humanSizeOf(dic.prefixes) + ", " + "suffixes=" + RamUsageTester.humanSizeOf(dic.suffixes) + ")"); } } } }