makeqstrdata: Don't include strings that are a net loss!

This commit is contained in:
Jeff Epler 2021-07-09 14:16:14 -05:00
parent 8836198ff1
commit 52e75c645d

View File

@ -390,8 +390,8 @@ def compute_huffman_coding(translations, compression_filename):
((s, -est_net_savings(s, occ)) for (s, occ) in counter.items()), key=lambda x: x[1] ((s, -est_net_savings(s, occ)) for (s, occ) in counter.items()), key=lambda x: x[1]
) )
# Pick the one with the highest score. # Pick the one with the highest score. The score must be negative.
if not scores: if not scores or scores[0][-1] >= 0:
break break
word = scores[0][0] word = scores[0][0]