max-long commited on
Commit
9daea47
·
verified ·
1 Parent(s): 7fd6f11

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
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 = [(ent["start"], ent["end"], ent["label"]) for ent in entities]
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="Click 'Get New Snippet' to load a random sample from the British Library Dataset",
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="People, Places", # Default example labels
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,