Fix CompressedChars filling up indefinitely, monitor exact node number.

This commit is contained in:
asofold 2012-09-04 09:08:19 +02:00
parent b262753f4f
commit 161548cbff

View File

@ -27,7 +27,11 @@ public class CompressedChars extends AbstractWordProcessor{
@Override @Override
public void start(MessageLetterCount message) { public void start(MessageLetterCount message) {
if (added + message.words.length > maxAdd) tree.clear(); // This allows adding up to maximum messge length more characters,
// but also allows to set size of nodes exactly.
// TODO: Some better method than blunt clear (extra LinkedHashSet/LRU?).
if (added > maxAdd) tree.clear();
added = 0;
} }
@Override @Override
@ -70,6 +74,7 @@ public class CompressedChars extends AbstractWordProcessor{
score += 0.2; score += 0.2;
if (entry.insertion.isEnd) score += 0.2; if (entry.insertion.isEnd) score += 0.2;
} }
if (len != entry.depth) added += len - entry.depth;
return score; return score;
} }