!7 p { Map tree = mechTreeCI("Übersetzungen nach deutsch | Wortbaum"); for (S in : mechList("Random English sentences")) { print(in); L tok = javaTok(in); printStruct(tok); for (int i = 1; i < l(tok); i += 2) scanFrom(tok, i, tree); printIndent(join(tok)); } } svoid scanFrom(L tok, int i, Map tree) { int j = i; Pair bestSolution = null; // replacement, index while (j < l(tok)) { S def = cast tree.get(""); if (def != null) bestSolution = pair(def, j); O t = tree.get(tok.get(j)); //print(j + " / " + tok.get(j) + " => " + sfu(t)); if (t == null) ret; if (t instanceof S) { replaceTokens(tok, i, j+1, (S) t); ret; } tree = (Map) t; j += 2; } if (bestSolution != null) replaceTokens(tok, i, bestSolution.b+1, bestSolution.a); }