Update app.py
Browse files
app.py
CHANGED
@@ -26,7 +26,7 @@ def ner(text: str, labels: str, threshold: float, nested_ner: bool):
|
|
26 |
entities = model.predict_entities(truncated_text, labels_list, flat_ner=not nested_ner, threshold=threshold)
|
27 |
|
28 |
# Prepare entities for color-coded display using gr.HighlightedText
|
29 |
-
highlights = [
|
30 |
|
31 |
# Return both the highlighted text and the raw entities in JSON format
|
32 |
return {
|
@@ -44,7 +44,7 @@ with gr.Blocks(title="General NER with Color-Coded Output") as demo:
|
|
44 |
|
45 |
# Display a random example
|
46 |
input_text = gr.Textbox(
|
47 |
-
value="
|
48 |
label="Text input",
|
49 |
placeholder="Enter your text here",
|
50 |
lines=5
|
@@ -52,7 +52,7 @@ with gr.Blocks(title="General NER with Color-Coded Output") as demo:
|
|
52 |
|
53 |
with gr.Row() as row:
|
54 |
labels = gr.Textbox(
|
55 |
-
value="
|
56 |
label="Labels",
|
57 |
placeholder="Enter your labels here (comma separated)",
|
58 |
scale=2,
|
|
|
26 |
entities = model.predict_entities(truncated_text, labels_list, flat_ner=not nested_ner, threshold=threshold)
|
27 |
|
28 |
# Prepare entities for color-coded display using gr.HighlightedText
|
29 |
+
highlights = [{"start": ent["start"], "end": ent["end"], "entity": ent["label"]} for ent in entities]
|
30 |
|
31 |
# Return both the highlighted text and the raw entities in JSON format
|
32 |
return {
|
|
|
44 |
|
45 |
# Display a random example
|
46 |
input_text = gr.Textbox(
|
47 |
+
value="The machine is fed by means of an endless apron, the wool entering at the smaller end...",
|
48 |
label="Text input",
|
49 |
placeholder="Enter your text here",
|
50 |
lines=5
|
|
|
52 |
|
53 |
with gr.Row() as row:
|
54 |
labels = gr.Textbox(
|
55 |
+
value="Machine, Wool", # Default example labels
|
56 |
label="Labels",
|
57 |
placeholder="Enter your labels here (comma separated)",
|
58 |
scale=2,
|