Spaces:
Runtime error
Runtime error
Commit
·
40fd323
1
Parent(s):
604e51a
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,13 +11,13 @@ examples = [
|
|
| 11 |
def ner(text):
|
| 12 |
doc = nlp(text)
|
| 13 |
final_output = []
|
| 14 |
-
flagged_categories = [
|
| 15 |
|
| 16 |
for ent in doc.ents:
|
| 17 |
label = ent.label_
|
| 18 |
|
| 19 |
if label not in flagged_categories:
|
| 20 |
-
output = {'entity': ent.label_,
|
| 21 |
final_output.append(output)
|
| 22 |
|
| 23 |
return {"text": text, "entities": final_output}
|
|
@@ -27,5 +27,6 @@ demo = gr.Interface(ner,
|
|
| 27 |
gr.HighlightedText(),
|
| 28 |
examples=examples)
|
| 29 |
|
| 30 |
-
|
|
|
|
| 31 |
demo.launch(debug=True)
|
|
|
|
| 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}
|
|
|
|
| 27 |
gr.HighlightedText(),
|
| 28 |
examples=examples)
|
| 29 |
|
| 30 |
+
|
| 31 |
+
if __name__ == "__main__":
|
| 32 |
demo.launch(debug=True)
|