max-long commited on
Commit
3d48f09
·
verified ·
1 Parent(s): 8154f86

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -35,14 +35,14 @@ def ner(text: str):
35
  if ent["label"] == "Textile Machinery"
36
  ]
37
 
38
- # Prepare entities for color-coded display using gr.HighlightedText
39
- highlights = [(ent["start"], ent["end"], ent["entity"]) for ent in textile_entities]
40
 
41
  # Return two outputs: one for the highlighted text and one for the entities in JSON format
42
  return {
43
  "text": text,
44
  "entities": highlights
45
- }, textile_entities # First output is for the highlighted text, second for the JSON component
46
 
47
  with gr.Blocks(title="Textile Machinery NER Demo") as demo:
48
  gr.Markdown(
@@ -90,4 +90,4 @@ with gr.Blocks(title="Textile Machinery NER Demo") as demo:
90
  )
91
 
92
  demo.queue()
93
- demo.launch(debug=True)
 
35
  if ent["label"] == "Textile Machinery"
36
  ]
37
 
38
+ # Prepare entities for color-coded display using gr.HighlightedText in the required dictionary format
39
+ highlights = [{"start": ent["start"], "end": ent["end"], "entity": ent["entity"]} for ent in textile_entities]
40
 
41
  # Return two outputs: one for the highlighted text and one for the entities in JSON format
42
  return {
43
  "text": text,
44
  "entities": highlights
45
+ }, textile_entities
46
 
47
  with gr.Blocks(title="Textile Machinery NER Demo") as demo:
48
  gr.Markdown(
 
90
  )
91
 
92
  demo.queue()
93
+ demo.launch(debug=True, share=True)