Update ner_tool.py
Browse files- ner_tool.py +4 -2
ner_tool.py
CHANGED
@@ -1,3 +1,5 @@
|
|
|
|
|
|
1 |
from transformers import pipeline
|
2 |
from transformers import Tool
|
3 |
|
@@ -18,6 +20,6 @@ class NamedEntityRecognitionTool(Tool):
|
|
18 |
print(f"Identified Entities: {entities}")
|
19 |
|
20 |
# Extract entity labels and return as a list
|
21 |
-
entity_labels = [entity
|
22 |
|
23 |
-
return entity_labels
|
|
|
1 |
+
# Updated NamedEntityRecognitionTool in ner_tool.py
|
2 |
+
|
3 |
from transformers import pipeline
|
4 |
from transformers import Tool
|
5 |
|
|
|
20 |
print(f"Identified Entities: {entities}")
|
21 |
|
22 |
# Extract entity labels and return as a list
|
23 |
+
entity_labels = [entity.get("entity", "UNKNOWN") for entity in entities]
|
24 |
|
25 |
+
return {"entities": entity_labels} # Return a dictionary with the specified output component
|