Spaces:
Runtime error
Runtime error
Commit
·
f44e244
1
Parent(s):
fe7bb2f
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,10 +11,14 @@ examples = [
|
|
| 11 |
def ner(text):
|
| 12 |
doc = nlp(text)
|
| 13 |
final_output = []
|
|
|
|
| 14 |
|
| 15 |
for ent in doc.ents:
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
return {"text": text, "entities": final_output}
|
| 20 |
|
|
|
|
| 11 |
def ner(text):
|
| 12 |
doc = nlp(text)
|
| 13 |
final_output = []
|
| 14 |
+
flagged_categories = ['CARDINAL', 'DATE', 'MONEY', 'PERCENT', 'QUANTITY', 'TIME', 'ORDINAL']
|
| 15 |
|
| 16 |
for ent in doc.ents:
|
| 17 |
+
label = ent.label_
|
| 18 |
+
|
| 19 |
+
if label not in flagged_categories:
|
| 20 |
+
output = {'entity': ent.label_, 'word': ent.text, 'start': int(ent.start_char), 'end': int(ent.end_char)}
|
| 21 |
+
final_output.append(output)
|
| 22 |
|
| 23 |
return {"text": text, "entities": final_output}
|
| 24 |
|