Commit
·
9506769
1
Parent(s):
09dc6c7
update
Browse files
app.py
CHANGED
@@ -17,7 +17,7 @@ ner_pipeline = pipeline(
|
|
17 |
|
18 |
|
19 |
def format_entities_as_html(entities):
|
20 |
-
excluded_keys = {"start", "end", "index", "
|
21 |
html_output = "<div>"
|
22 |
|
23 |
for entity in entities:
|
@@ -50,7 +50,7 @@ def prepare_entities_for_highlight(text, results):
|
|
50 |
print(f"Original text: {text}")
|
51 |
print("Results:", results)
|
52 |
# it should look like:
|
53 |
-
# [{'entity': 'org.ent.pressagency.Reuters', 'score': np.float32(98.47), 'index': 78, '
|
54 |
for entity in results:
|
55 |
entity_span = (entity["start"], entity["end"])
|
56 |
|
@@ -61,7 +61,6 @@ def prepare_entities_for_highlight(text, results):
|
|
61 |
entity["start"] : entity["end"]
|
62 |
].strip() # Ensure we're working with the correct portion of the text
|
63 |
entity["text"] = entity_text
|
64 |
-
entity.pop("word")
|
65 |
print(f"Entity text: {entity}")
|
66 |
|
67 |
entities.append(entity)
|
|
|
17 |
|
18 |
|
19 |
def format_entities_as_html(entities):
|
20 |
+
excluded_keys = {"start", "end", "index", "text"} # Keys to exclude from the output
|
21 |
html_output = "<div>"
|
22 |
|
23 |
for entity in entities:
|
|
|
50 |
print(f"Original text: {text}")
|
51 |
print("Results:", results)
|
52 |
# it should look like:
|
53 |
+
# [{'entity': 'org.ent.pressagency.Reuters', 'score': np.float32(98.47), 'index': 78, 'text': 'Reuters', 'start': 440, 'end': 447}]
|
54 |
for entity in results:
|
55 |
entity_span = (entity["start"], entity["end"])
|
56 |
|
|
|
61 |
entity["start"] : entity["end"]
|
62 |
].strip() # Ensure we're working with the correct portion of the text
|
63 |
entity["text"] = entity_text
|
|
|
64 |
print(f"Entity text: {entity}")
|
65 |
|
66 |
entities.append(entity)
|