marcelomoreno26 commited on
Commit
d64e173
1 Parent(s): 6cfa228

Update model_functions.py

Browse files
Files changed (1) hide show
  1. model_functions.py +11 -2
model_functions.py CHANGED
@@ -86,6 +86,15 @@ def get_NER(text, pipe):
86
  filtered_results = sorted(unique_entities.values(), key=lambda x: x['start'])
87
  # Format the results for a table display
88
  formatted_results = [[ent['word'], ent['entity_group']] for ent in filtered_results]
89
-
90
- return formatted_results
 
 
 
 
 
 
 
 
 
91
 
 
86
  filtered_results = sorted(unique_entities.values(), key=lambda x: x['start'])
87
  # Format the results for a table display
88
  formatted_results = [[ent['word'], ent['entity_group']] for ent in filtered_results]
89
+ filtered_results = []
90
+ for entity in formatted_results:
91
+ if entity[1] == 'ORG':
92
+ # Split the 'word' by spaces and count the number of words
93
+ if len(entity[0].split()) <= 2:
94
+ filtered_results.append(entity)
95
+ else:
96
+ # Add non-ORG entities without filtering
97
+ filtered_results.append(entity)
98
+
99
+ return filtered_results
100