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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -32,16 +32,17 @@ def ner(text: str):
32
  "score": ent.get("score", 0),
33
  }
34
  for ent in entities
35
- if ent["label"] == "Textile Machinery" # Exact match with capitalization
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 {
42
  "text": text,
43
  "entities": highlights
44
- }
45
 
46
  with gr.Blocks(title="Textile Machinery NER Demo") as demo:
47
  gr.Markdown(
 
32
  "score": ent.get("score", 0),
33
  }
34
  for ent in entities
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(