We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 19dbd9d commit bad9c8aCopy full SHA for bad9c8a
evaluation_function/models/shannon_words_ngram.py
@@ -36,6 +36,10 @@ def get_counts(n=3, dev=False):
36
try:
37
with bz2.BZ2File(FILE, "rb") as f:
38
cache = pickle.load(f)
39
+ if not isinstance(cache, dict):
40
+ raise RuntimeError(f"Loaded cache is {type(cache)}, not dict — contents: {str(cache)[:300]}")
41
+ if n not in cache:
42
+ raise RuntimeError(f"Loaded keys={list(cache.keys())[:10]} (len={len(cache)}) — expected {n}")
43
except Exception as e:
44
raise RuntimeError(f"Failed to load {FILE}: {e}")
45
elif dev: # from here the deployed version will not work because the corpora are not bundled (to save space)
0 commit comments