static int ai_tok_combinePhrases_maxPhraseLength = 3; // 3 words, see #1011207 static L ai_tok_combinePhrases(L tok) { ret ai_tok_combinePhrases(tok, f isKnownPhrase); } static L ai_tok_combinePhrases(L tok, O isKnownPhrase) { new L l; int n = l(tok); bigloop: for i over tok: { S t = tok.get(i); if (odd(i)) { S phrase = t; int j = i+2; while (j < n && j < i+ai_tok_combinePhrases_maxPhraseLength*2) { phrase += " " + tok.get(j); if (isTrue(callF(isKnownPhrase, phrase))) { l.add(joinSubList(tok, i, j+1)); i = j; continue bigloop; } j += 2; } } l.add(t); } ret l; }