Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -32,18 +32,8 @@ def merge_tokens(tokens):
|
|
| 32 |
def ner(input):
|
| 33 |
output = get_completion(input)
|
| 34 |
merged_tokens = merge_tokens(output)
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
idx = 0
|
| 38 |
-
for i in output:
|
| 39 |
-
result += text[idx:i["start"]]
|
| 40 |
-
ent = id2label[i["entity_group"]]
|
| 41 |
-
result += text[i["start"]:i["end"]] + f"{ent}"
|
| 42 |
-
idx = i["end"]
|
| 43 |
-
result+=text[idx:]
|
| 44 |
-
print(result)
|
| 45 |
-
return {"text": result}
|
| 46 |
-
# return {"text": input, "entities": merged_tokens}
|
| 47 |
|
| 48 |
gr.close_all()
|
| 49 |
demo = gr.Interface(fn=ner,
|
|
|
|
| 32 |
def ner(input):
|
| 33 |
output = get_completion(input)
|
| 34 |
merged_tokens = merge_tokens(output)
|
| 35 |
+
|
| 36 |
+
return {"text": input, "entities": merged_tokens}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
gr.close_all()
|
| 39 |
demo = gr.Interface(fn=ner,
|