Transpiled version (15031L) is out of date.
1 | // A = parameter type |
2 | srecord noeq AIC_EvaluateParameter<A>( |
3 | S parameterName, |
4 | Cl<A> parameterValues, |
5 | IVF2<A, AdaptiveIdentifierCompression> applyParameter) { |
6 | |
7 | new AICDemo demo; |
8 | new Map<A, Int> scores; |
9 | new LL<PairS> tokenByToken; |
10 | |
11 | run { |
12 | fOr (param : parameterValues) { |
13 | demo.adapt = aic -> applyParameter.get(param, aic); |
14 | int l = l(demo.compress()); |
15 | tokenByToken.add(demo.tokenByToken); |
16 | printVars(+param, +l, escapeWordsUsed := demo.aicComp.escapeWordsUsed); |
17 | demo.decompress(); |
18 | if (!demo.decompressedOK) |
19 | fail(parameterName + "=" + param + " breaks the algorithm"); |
20 | scores.put(param, l); |
21 | } |
22 | |
23 | printScores(); |
24 | } |
25 | |
26 | void printScores { |
27 | print("Best values for " + parameterName + ":"); |
28 | pnl(mapSortedByValue(scores)); |
29 | } |
30 | |
31 | void printTokenByTokenDiffs(bool printSameLengthEncodings default false) { |
32 | LL<PairS> transposed = transpose(tokenByToken); |
33 | for i over transposed: { |
34 | LPairS row = transposed.get(i); |
35 | LS encodings = pairsB(row); |
36 | S token = pairA(first(row)); |
37 | |
38 | if (!printSameLengthEncodings && allEq(map l(encodings))) continue; |
39 | print("Token " + i + ": " + quote(token) + " => " + sfu(encodings)); |
40 | } |
41 | } |
42 | } |
Began life as a copy of #1034373
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1034534 |
Snippet name: | AIC_EvaluateParameter |
Eternal ID of this version: | #1034534/11 |
Text MD5: | 3d9df94561f2d17ea280c5ee26ee86f0 |
Author: | stefan |
Category: | javax / compressing text |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-02-11 21:07:32 |
Source code size: | 1283 bytes / 42 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 187 / 292 |
Version history: | 10 change(s) |
Referenced in: | [show references] |