- new DictFileParser(charset, false, DictFileParser.DOUBLE_COLON, DictFileParser.PIPE, dictionaryBuilder, dictionaryBuilder.indexBuilders.toArray(new IndexBuilder[0]), null).parseFile(file);
- } else if ("wiktionary".equals(inputFormat)) {
- throw new RuntimeException();
-// new WiktionaryXmlParser(dict).parse(file);
+ final boolean flipColumns = "true".equals(keyValueArgs.remove(prefix + "FlipColumns"));
+ new DictFileParser(charset, flipColumns, DictFileParser.DOUBLE_COLON, DictFileParser.PIPE, dictionaryBuilder, dictionaryBuilder.indexBuilders.toArray(new IndexBuilder[0]), null).parse(file, entrySource, pageLimit);
+ } else if ("enwiktionary".equals(inputFormat)) {
+ final String type = keyValueArgs.remove(prefix + "WiktionaryType");
+ final Pattern langPattern = Pattern.compile(keyValueArgs.remove(prefix + "LangPattern"), Pattern.CASE_INSENSITIVE);
+ final Pattern langCodePattern = Pattern.compile(keyValueArgs.remove(prefix + "LangCodePattern"));
+ final int enIndex = Integer.parseInt(keyValueArgs.remove(prefix + "EnIndex")) - 1;
+
+ if (enIndex < 0 || enIndex >= 2) {
+ fatalError("Must be 1 or 2: " + prefix + "EnIndex");
+ }
+ final Parser parser;
+ if ("EnToTranslation".equals(type)) {
+ parser = new EnToTranslationParser(dictionaryBuilder.indexBuilders.get(enIndex), dictionaryBuilder.indexBuilders.get(1-enIndex),
+ langPattern, langCodePattern, enIndex != 0);
+ } else if ("EnForeign".equals(type)) {
+ parser = new EnForeignParser(dictionaryBuilder.indexBuilders.get(enIndex), dictionaryBuilder.indexBuilders.get(1-enIndex),
+ langPattern, langCodePattern, enIndex != 0);
+ } else {
+ fatalError("Invalid WiktionaryType (use EnToTranslation or EnForeign): " + type);
+ return;
+ }
+ parser.parse(file, entrySource, pageLimit);
+ } else if (EnTranslationToTranslationParser.NAME.equals(inputFormat)) {
+ final String code1 = keyValueArgs.remove(prefix + "LangPattern1");
+ final String code2 = keyValueArgs.remove(prefix + "LangPattern2");
+ if (code1 == null || code2 == null) {
+ fatalError("Must specify LangPattern1 and LangPattern2.");
+ return;
+ }
+ final Pattern codePattern1 = Pattern.compile(code1, Pattern.CASE_INSENSITIVE);
+ final Pattern codePattern2 = Pattern.compile(code2, Pattern.CASE_INSENSITIVE);
+ new EnTranslationToTranslationParser(dictionaryBuilder.indexBuilders, new Pattern[] {codePattern1, codePattern2}).parse(file, entrySource, pageLimit);
+ } else if (WholeSectionToHtmlParser.NAME.equals(inputFormat)) {
+ final int titleIndex = Integer.parseInt(keyValueArgs.remove(prefix + "TitleIndex")) - 1;
+ new WholeSectionToHtmlParser(dictionaryBuilder.indexBuilders.get(titleIndex)).parse(file, entrySource, pageLimit);