Skip to content

Commit cec4bc6

Browse files
authored
Merge pull request #180 from mammothb/feature/warn-when-failed-to-parse-frequency
Specify that frequency count must be 64-bit int
2 parents 532d4e1 + a7f4453 commit cec4bc6

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

symspellpy/symspellpy.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import string
2525
import sys
2626
import unicodedata
27+
import warnings
2728
from collections import defaultdict
2829
from itertools import cycle
2930
from pathlib import Path
@@ -291,6 +292,8 @@ def load_bigram_dictionary(
291292
"""Loads multiple dictionary entries from a file of word/frequency count
292293
pairs.
293294
295+
**NOTE**: Frequency count should be an integer that fits within 64 bits.
296+
294297
**NOTE**: Merges with any dictionary data already loaded.
295298
296299
Args:
@@ -323,6 +326,8 @@ def load_dictionary(
323326
"""Loads multiple dictionary entries from a file of word/frequency count
324327
pairs.
325328
329+
**NOTE**: Frequency count should be an integer that fits within 64 bits.
330+
326331
**NOTE**: Merges with any dictionary data already loaded.
327332
328333
Args:
@@ -1090,6 +1095,7 @@ def _load_bigram_dictionary_stream(
10901095
continue
10911096
count = helpers.try_parse_int64(parts[count_index])
10921097
if count is None:
1098+
warnings.warn("Failed to parse frequency count as a 64 bit integer.")
10931099
continue
10941100
key = (
10951101
f"{parts[term_index]} {parts[term_index + 1]}"
@@ -1128,6 +1134,7 @@ def _load_dictionary_stream(
11281134
continue
11291135
count = helpers.try_parse_int64(parts[count_index])
11301136
if count is None:
1137+
warnings.warn("Failed to parse frequency count as a 64 bit integer.")
11311138
continue
11321139
key = parts[term_index]
11331140
self.create_dictionary_entry(key, count)

0 commit comments

Comments
 (0)