Modify README and fix PredictLangWorker

parent bfde3ad5
Pipeline #1848 failed with stage
in 47 seconds
...@@ -9,6 +9,6 @@ Use docker to build and run image: ...@@ -9,6 +9,6 @@ Use docker to build and run image:
``` ```
docker build -t <name> . docker build -t <name> .
docker run <name> -v "/samba:/samba" docker run -v /samba:/samba <name>
``` ```
import fasttext import fasttext
import nlp_ws import nlp_ws
class PredictLangWorker(nlp_ws.NLPWorker): class PredictLangWorker(nlp_ws.NLPWorker):
def __init__(self): def __init__(self):
self.model = fasttext.load_model("lid.176.bin") self.model = fasttext.load_model("lid.176.bin")
def process(self, input_file: str, def process(self, input_file: str, task_options: dict, output_file: str) -> None:
task_options: dict,
output_file: str) -> None:
with open(input_file, "r") as f: with open(input_file, "r") as f:
text ='\n', ' ') text ='\n',' ')
predict = self.model.predict(text)[0][0] predict = self.model.predict(text)[0][0]
with open(output_file, "w") as f: with open(output_file, "w") as f:
f.write(predict) f.write(text+ predict)
return self.model.predict(str(text)) print(predict)
return predict
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment