X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcom%2Fhughes%2Fandroid%2Fdictionary%2Fparser%2Fwiktionary%2FEnFunctionCallbacks.java;h=3161f4abeec1d832f32b63a98f2623064e22ba05;hb=752c81f1f8ec816865611477896093d81a77f90a;hp=955e957536c5614d4bf83b4ff9bed7e1cd001758;hpb=972c207ed3b98a7bee6b472db1d94391f4dbf24f;p=DictionaryPC.git diff --git a/src/com/hughes/android/dictionary/parser/wiktionary/EnFunctionCallbacks.java b/src/com/hughes/android/dictionary/parser/wiktionary/EnFunctionCallbacks.java index 955e957..3161f4a 100644 --- a/src/com/hughes/android/dictionary/parser/wiktionary/EnFunctionCallbacks.java +++ b/src/com/hughes/android/dictionary/parser/wiktionary/EnFunctionCallbacks.java @@ -64,6 +64,15 @@ class EnFunctionCallbacks { callbacks.put("rfquote", callback); callbacks.put("attention", callback); callbacks.put("zh-attention", callback); + callbacks.put("top2", callback); + callbacks.put("mid2", callback); + callbacks.put("top3", callback); + callbacks.put("mid3", callback); + callbacks.put("bottom", callback); + callbacks.put("rel-mid", callback); + callbacks.put("rel-mid3", callback); + callbacks.put("rel-mid4", callback); + callbacks.put("rel-bottom", callback); callback = new AppendName(); callbacks.put("...", callback); @@ -234,6 +243,7 @@ class EnFunctionCallbacks { final Map namedArgs, final T parser, final AppendAndIndexWikiCallback appendAndIndexWikiCallback) { + //namedArgs.remove("lang"); if (!namedArgs.isEmpty()) { EnParser.LOG.warning("weird encoding: " + wikiTokenizer.token()); return false; @@ -617,6 +627,18 @@ class EnFunctionCallbacks { appendAndIndexWikiCallback.builder.append(" {").append(gender).append("}, "); appendAndIndexWikiCallback.dispatch(plural, null, null); appendAndIndexWikiCallback.builder.append(" {pl}"); + final String f = namedArgs.remove("f"); + if (f != null) { + appendAndIndexWikiCallback.builder.append(", "); + appendAndIndexWikiCallback.dispatch(f, null, null); + appendAndIndexWikiCallback.builder.append(" {f}"); + } + final String m = namedArgs.remove("f"); + if (m != null) { + appendAndIndexWikiCallback.builder.append(", "); + appendAndIndexWikiCallback.dispatch(m, null, null); + appendAndIndexWikiCallback.builder.append(" {m}"); + } parser.wordForms.add(singular); parser.wordForms.add(plural); if (!namedArgs.isEmpty() || args.size() > 4) { @@ -643,49 +665,6 @@ class EnFunctionCallbacks { // Italian stuff // ----------------------------------------------------------------------- - static void passThroughOrFillIn(final Map namedArgs, final String key, final String fillIn, final boolean quoteToEmpty) { - final String value = namedArgs.get(key); - if (quoteToEmpty && "''".equals(value)) { - namedArgs.put(key, ""); - return; - } - if (value == null || value.equals("")) { - namedArgs.put(key, fillIn); - } - } - - static final List it_number_s_p = Arrays.asList("s", "p"); - static final List it_person_1_2_3 = Arrays.asList("1", "2", "3"); - static final List it_reflexive_pronouns = Arrays.asList("mi ", "ti ", "si ", "ci ", "vi ", "si "); - static final List it_empty = Arrays.asList("", "", "", "", "", ""); - static void it_conj_passMood(final Map namedArgs, final String moodName, final boolean quoteToEmpty, final String root, final List suffixes) { - assert suffixes.size() == 6; - int i = 0; - for (final String number : it_number_s_p) { - for (final String person : it_person_1_2_3) { - passThroughOrFillIn(namedArgs, String.format("%s%s%s", moodName, person, number), root + suffixes.get(i), quoteToEmpty); - ++i; - } - } - } - - private static void outputKeyVariations(AppendAndIndexWikiCallback appendAndIndexWikiCallback, - final StringBuilder builder, final String keyBase, Map namedArgs, boolean isForm) { - for (int suffix = 0; suffix <= 4; ++suffix) { - final String key = suffix == 0 ? keyBase : keyBase + suffix; - final String val = namedArgs.remove(key); - if (val != null) { - if (suffix > 0) { - builder.append(", "); - } - appendAndIndexWikiCallback.dispatch(val, null); - if (isForm) { - appendAndIndexWikiCallback.parser.addLinkToCurrentEntry(val, EntryTypeName.WIKTIONARY_INFLECTED_FORM_MULTI); - } - } - } - } - static final class it_conj_are implements FunctionCallback { final it_conj dest; it_conj_are(it_conj dest) { @@ -1060,7 +1039,14 @@ static final class it_conj_are implements Fu if (!namedArgs.isEmpty()) { System.err.println("NON-EMPTY namedArgs: " + namedArgs); - assert false; + if ("muovesse".equals(namedArgs.get("impsib3s2"))) { + return false; + } + if ("percuotesse".equals(namedArgs.get("impsib3s2"))) { + return false; + } + // Too many to deal with: + //assert false; return false; } @@ -1089,4 +1075,49 @@ static final class it_conj_are implements Fu builder.append("\n"); } } + + static void passThroughOrFillIn(final Map namedArgs, final String key, final String fillIn, final boolean quoteToEmpty) { + final String value = namedArgs.get(key); + if (quoteToEmpty && "''".equals(value)) { + namedArgs.put(key, ""); + return; + } + if (value == null || value.equals("")) { + namedArgs.put(key, fillIn); + } + } + + static final List it_number_s_p = Arrays.asList("s", "p"); + static final List it_person_1_2_3 = Arrays.asList("1", "2", "3"); + static final List it_reflexive_pronouns = Arrays.asList("mi ", "ti ", "si ", "ci ", "vi ", "si "); + static final List it_empty = Arrays.asList("", "", "", "", "", ""); + static void it_conj_passMood(final Map namedArgs, final String moodName, final boolean quoteToEmpty, final String root, final List suffixes) { + assert suffixes.size() == 6; + int i = 0; + for (final String number : it_number_s_p) { + for (final String person : it_person_1_2_3) { + passThroughOrFillIn(namedArgs, String.format("%s%s%s", moodName, person, number), root + suffixes.get(i), quoteToEmpty); + ++i; + } + } + } + + private static void outputKeyVariations(AppendAndIndexWikiCallback appendAndIndexWikiCallback, + final StringBuilder builder, final String keyBase, Map namedArgs, boolean isForm) { + for (int suffix = 0; suffix <= 4; ++suffix) { + final String key = suffix == 0 ? keyBase : keyBase + suffix; + final String val = namedArgs.remove(key); + if (val != null && !val.trim().equals("")) { + if (suffix > 0) { + builder.append(", "); + } + appendAndIndexWikiCallback.dispatch(val, null); + if (isForm) { + appendAndIndexWikiCallback.parser.addLinkToCurrentEntry(val, EntryTypeName.WIKTIONARY_INFLECTED_FORM_MULTI); + } + } + } + } + + } \ No newline at end of file