sclass AICDemo { settable S snippetID = #1034022; swappable S makeInputText() { ret loadSnippet_cached(snippetID); } settable S inputText; settable S compressedText; settable S decompressedText; AdaptiveIdentifierCompression aicComp; AdaptiveIdentifierCompression aicDecomp; void compress { if (inputText == null) inputText = makeInputText(); aicComp = new AdaptiveIdentifierCompression; new StringBuilder buf; for (t : javaTok(text)) buf.append(aic.decode(t)); compressedText = str(buf); print("Compressed " + nChars(inputText) + " => " + nChars(compressedText) + " = " + doubleRatio(l(compressedText), l(inputText))); } void decompress { aicDecomp = new AdaptiveIdentifierCompression; new StringBuilder buf; for (t : javaTok(compressedText)) buf.append(aic.decode(t)); decompressedText = str(buf); if (inputText != null) { int correct = lCommonPrefix(inputText, decompressedText); print("Decompressed text correct for " + nChars(correct) + " out of " + nChars(inputText)); } } }