// A = parameter type srecord noeq AIC_EvaluateParameter( S parameterName, Cl parameterValues, IVF2 applyParameter) { new AICDemo demo; new Map scores; new LL tokenByToken; run { fOr (param : parameterValues) { demo.adapt = aic -> applyParameter.get(param, aic); int l = l(demo.compress()); tokenByToken.add(demo.tokenByToken); printVars(+param, +l, escapeWordsUsed := demo.aicComp.escapeWordsUsed); demo.decompress(); if (!demo.decompressedOK) fail(parameterName + "=" + param + " breaks the algorithm"); scores.put(param, l); } printScores(); } void printScores { print("Best values for " + parameterName + ":"); pnl(mapSortedByValue(scores)); } void printTokenByTokenDiffs(bool printSameLengthEncodings default false) { LL transposed = transpose(tokenByToken); for i over transposed: { LPairS row = transposed.get(i); LS encodings = pairsB(row); S token = pairA(first(row)); if (!printSameLengthEncodings && allEq(map l(encodings))) continue; print("Token " + i + ": " + quote(token) + " => " + sfu(encodings)); } } }