Update app.py
Browse files
app.py
CHANGED
@@ -262,9 +262,10 @@ def text_to_kenlm(
|
|
262 |
f.write(" ".join(results))
|
263 |
|
264 |
file_name = "/tmp/my_model.arpa"
|
|
|
265 |
|
266 |
# Commands to run in the container
|
267 |
-
if
|
268 |
cmd = (
|
269 |
f"{kenlm_bin}/lmplz -T /tmp -S 80% --text {intermediate_file} --arpa /tmp/my_model.arpa -o {_order} --prune {_arpa_prune} --discount_fallback",
|
270 |
)
|
@@ -295,7 +296,7 @@ def text_to_kenlm(
|
|
295 |
file_name = file_name_fixed
|
296 |
|
297 |
if _do_limit_topk:
|
298 |
-
|
299 |
|
300 |
_, vocab_str = convert_and_filter_topk(intermediate_file, _topk_words)
|
301 |
|
@@ -304,7 +305,7 @@ def text_to_kenlm(
|
|
304 |
os.path.join(kenlm_bin, "filter"),
|
305 |
"single",
|
306 |
"model:{}".format(file_name),
|
307 |
-
|
308 |
],
|
309 |
input=vocab_str.encode("utf-8"),
|
310 |
check=True,
|
|
|
262 |
f.write(" ".join(results))
|
263 |
|
264 |
file_name = "/tmp/my_model.arpa"
|
265 |
+
_do_model = True
|
266 |
|
267 |
# Commands to run in the container
|
268 |
+
if _do_model:
|
269 |
cmd = (
|
270 |
f"{kenlm_bin}/lmplz -T /tmp -S 80% --text {intermediate_file} --arpa /tmp/my_model.arpa -o {_order} --prune {_arpa_prune} --discount_fallback",
|
271 |
)
|
|
|
296 |
file_name = file_name_fixed
|
297 |
|
298 |
if _do_limit_topk:
|
299 |
+
file_name_words = f"/tmp/my_model-{_topk_words}-words.arpa"
|
300 |
|
301 |
_, vocab_str = convert_and_filter_topk(intermediate_file, _topk_words)
|
302 |
|
|
|
305 |
os.path.join(kenlm_bin, "filter"),
|
306 |
"single",
|
307 |
"model:{}".format(file_name),
|
308 |
+
file_name_words,
|
309 |
],
|
310 |
input=vocab_str.encode("utf-8"),
|
311 |
check=True,
|