Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 = [
|
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,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)
|