static StringBuilder scoreTextPredictAlgo_buf; static double scoreTextPredictAlgo(Algorithm algorithm, S text) { ret scoreTextPredictAlgo(algorithm, text, 0, 0); } static double scoreTextPredictAlgo(Algorithm algorithm, S text, int descLength, int pivotLength) { long time = now(); int score = 0; int n = l(text); for (int pos = 0; pos < n; ) { S s = algorithm.predict(n-pos); if (empty(s)) s = " "; // We're lenient if (l(s) > n-pos) s = substring(s, 0, n-pos); if (scoreTextPredictAlgo_buf != null) scoreTextPredictAlgo_buf.append(s); int j = pos+l(s); S real = substring(text, pos, j); score += getNumberOfEqualCharacters(real, s); algorithm.feed(real); pos = j; } double score2 = score*100.0/n-lengthPunishment(descLength, pivotLength); done_always(time, "SCORE: " + score + "/" + n + " = " + formatDouble(score2, 2) + "%"); if (lastSilentException() != null) printStackTrace(lastSilentException()); ret score2; }