Spaces:
Runtime error
Runtime error
liewchooichin
commited on
Commit
•
7ab4587
1
Parent(s):
4e393b7
get only score at least 0.8
Browse files
app.py
CHANGED
@@ -39,15 +39,23 @@ def predict(sentence):
|
|
39 |
|
40 |
# Get the prediction of ner from the model
|
41 |
result_ner = ner_task(sentence)
|
42 |
-
formatted_ner =
|
|
|
43 |
# Print individual entities.
|
44 |
# Start the count from 1 for intuitive reading.
|
45 |
for i, result in enumerate(result_ner):
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
return token_pieces, formatted_ner
|
53 |
|
|
|
39 |
|
40 |
# Get the prediction of ner from the model
|
41 |
result_ner = ner_task(sentence)
|
42 |
+
formatted_ner = ""
|
43 |
+
entities_count = 0
|
44 |
# Print individual entities.
|
45 |
# Start the count from 1 for intuitive reading.
|
46 |
for i, result in enumerate(result_ner):
|
47 |
+
# Only get the result where score is at least 0.8
|
48 |
+
if result['score'] < 0.8:
|
49 |
+
continue;
|
50 |
+
else:
|
51 |
+
entities_count += 1
|
52 |
+
formatted_ner += f"Number: {entities_count} \n" \
|
53 |
+
+ f"Entity: {result['entity_group']}\n" \
|
54 |
+
+ f"Word group: {result['word']}\n" \
|
55 |
+
+ f"Score: {result['score']}\n"
|
56 |
+
formatted_ner += f"{result}\n\n"
|
57 |
+
|
58 |
+
formatted_ner += f"Number of predicted entities: {entities_count}\n\n"
|
59 |
|
60 |
return token_pieces, formatted_ner
|
61 |
|