Update README.md
Browse files
README.md
CHANGED
@@ -27,18 +27,19 @@ import fasttext
|
|
27 |
model = fasttext.load_model("model_textbook_quality.bin")
|
28 |
|
29 |
|
30 |
-
def replace_newlines(text):
|
31 |
return re.sub("\n+", " ", text)
|
32 |
|
33 |
|
34 |
-
def predict(text_list: List[str]):
|
35 |
text_list = [replace_newlines(text) for text in text_list]
|
36 |
pred = model.predict(text_list)
|
37 |
-
return [{"label": l[0].lstrip("__label__"), "score": s[0]}
|
|
|
38 |
|
39 |
|
40 |
predict(["Hi"])
|
41 |
-
# Output: {'label': 'LOW_QUALITY', 'score': 1.00001}
|
42 |
|
43 |
```
|
44 |
|
|
|
27 |
model = fasttext.load_model("model_textbook_quality.bin")
|
28 |
|
29 |
|
30 |
+
def replace_newlines(text: str) -> str:
|
31 |
return re.sub("\n+", " ", text)
|
32 |
|
33 |
|
34 |
+
def predict(text_list: List[str]) -> List[dict]:
|
35 |
text_list = [replace_newlines(text) for text in text_list]
|
36 |
pred = model.predict(text_list)
|
37 |
+
return [{"label": l[0].lstrip("__label__"), "score": s[0]}
|
38 |
+
for l, s in zip(*pred)]
|
39 |
|
40 |
|
41 |
predict(["Hi"])
|
42 |
+
# Output: [{'label': 'LOW_QUALITY', 'score': 1.00001}]
|
43 |
|
44 |
```
|
45 |
|