Merge pull request #6455 from jepler/require-multi-occur

Only check the savings if a word occurs at least twice
This commit is contained in:
Scott Shawcroft 2022-06-03 14:58:02 -07:00 committed by GitHub
commit 5c9768965c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -400,7 +400,8 @@ def compute_huffman_coding(translations, compression_filename):
# words[] array.
scores = sorted(
((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() if occ > 1),
key=lambda x: x[1],
)
# Pick the one with the highest score. The score must be negative.