Spaces:
Runtime error
Runtime error
Remove corrupt KenLM model files.
Browse files
perplexity_lenses/perplexity.py
CHANGED
@@ -7,7 +7,11 @@ import kenlm
|
|
7 |
class KenlmModel:
|
8 |
def __init__(self, language):
|
9 |
download_kenlm_model(language)
|
10 |
-
|
|
|
|
|
|
|
|
|
11 |
|
12 |
@classmethod
|
13 |
def from_pretrained(cls, language: str):
|
|
|
7 |
class KenlmModel:
|
8 |
def __init__(self, language):
|
9 |
download_kenlm_model(language)
|
10 |
+
try:
|
11 |
+
self.model = kenlm.Model(f"{language}.arpa.bin")
|
12 |
+
except OSError:
|
13 |
+
os.remove(f"{language}.arpa.bin")
|
14 |
+
raise OSError("File was corrupt and should have been removed. Please, retry.")
|
15 |
|
16 |
@classmethod
|
17 |
def from_pretrained(cls, language: str):
|