elnasharomar2 commited on
Commit
ee3b001
·
verified ·
1 Parent(s): d36f1a5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -12
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
- ## modification
36
- result =""
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,