emanuelaboros commited on
Commit
69a7750
·
1 Parent(s): 0300379

lets see how the hihgt works

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -55,7 +55,8 @@ def extract_entities(sentence):
55
  print(f"Original text: {sentence}")
56
  print("Results:", results)
57
  # it should look like:
58
- # [{'entity': 'org.ent.pressagency.Reuters', 'score': np.float32(98.47), 'index': 78, 'text': 'Reuters', 'start': 440, 'end': 447}]
 
59
  for entity in results:
60
  entity_span = (entity["start"], entity["end"])
61
 
@@ -66,7 +67,9 @@ def extract_entities(sentence):
66
  entity["start"] : entity["end"]
67
  ].strip() # Ensure we're working with the correct portion of the text
68
  entity["surface"] = entity_text
69
- entity["entity"] = entity["type"]
 
 
70
  # print(f"Entity text: {entity}")
71
 
72
  entities.append(entity)
@@ -75,6 +78,7 @@ def extract_entities(sentence):
75
  # entities = sorted(entities, key=lambda x: x["start"])
76
  return {"text": sentence, "entities": entities}
77
 
 
78
  # Create Gradio interface
79
  def ner_app_interface():
80
  input_sentence = gr.Textbox(
 
55
  print(f"Original text: {sentence}")
56
  print("Results:", results)
57
  # it should look like:
58
+ # [{'entity': 'org.ent.pressagency.Reuters', 'score': np.float32(98.47),
59
+ # 'index': 78, 'text': 'Reuters', 'start': 440, 'end': 447}]
60
  for entity in results:
61
  entity_span = (entity["start"], entity["end"])
62
 
 
67
  entity["start"] : entity["end"]
68
  ].strip() # Ensure we're working with the correct portion of the text
69
  entity["surface"] = entity_text
70
+ label = f"{entity['type']} ({entity.get('title', 'No title')}, {entity.get('name', 'No name')}, {entity.get('function', 'No function')})"
71
+
72
+ entity["entity"] = label
73
  # print(f"Entity text: {entity}")
74
 
75
  entities.append(entity)
 
78
  # entities = sorted(entities, key=lambda x: x["start"])
79
  return {"text": sentence, "entities": entities}
80
 
81
+
82
  # Create Gradio interface
83
  def ner_app_interface():
84
  input_sentence = gr.Textbox(