static Triple ai_tripelize(S s) { S x = ""; if (endsWith(s, "?")) x = " (?)"; // e.g. for "Al Gore invented the Internet?" Triple t = ai_tripelize_impl(dropPunctuationAtEnd(s)); if (t != null) t.b += x; ret t; } static Triple ai_tripelize_impl(S s) { L tok = nlTok(s); S a = get(tok, 1); if (a == null) null; if (ai_questionWord_1(a)) { tok = subList(tok, 2); a = get(tok, 1); } if (ai_yesNoQuestionWord_1(a) && neqicOneOf(a, "am", "are", "is")) { L tok2 = subList(tok, 2); int i = indexOfFirstVerb(tok2); S v = get(tok2, i); if (v != null) { if (eqic(a, "does")) v = verbToThirdPerson(v) + "?"; else if (eqic(a, "do")) v = v + "?"; else if (eqic(a, "did")) v = verbToPast(v) + "?"; else v = a + " " + v + "?"; ret triple("", v, ""); } } if (isVerb(a)) { tok = subList(tok, 2); //int i = ai_splitTwoNounPhrases(tok); int i = ai_endOfNounPhrase(tok); ret triple( trimJoinSubList(tok, 0, i), a + "?", trimJoinSubList(tok, i)); } int i = ai_endOfNounPhrase(tok); int j = indexOfFirstVerb(tok, i); ret triple( trimJoinSubList(tok, 0, j), tok.get(j), trimJoinSubList(tok, j+2)); }