Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -62,12 +62,12 @@ def process_ner(text: str, pipeline) -> dict:
|
|
| 62 |
"entity": entity_type,
|
| 63 |
"start": token['start'],
|
| 64 |
"end": token['end'],
|
| 65 |
-
"
|
| 66 |
"tokens": [token['word']]
|
| 67 |
}
|
| 68 |
else:
|
| 69 |
current_entity['end'] = token['end']
|
| 70 |
-
current_entity['
|
| 71 |
current_entity['tokens'].append(token['word'])
|
| 72 |
|
| 73 |
if current_entity is not None:
|
|
@@ -129,9 +129,9 @@ def generate_wordcloud(entities: List[Dict], color_map: Dict[str, str], file_pat
|
|
| 129 |
for entity in entities:
|
| 130 |
cleaned_entity = re.sub(r'^\W+', '', ' '.join(entity['tokens']))
|
| 131 |
entity_texts.append(cleaned_entity)
|
| 132 |
-
entity_scores.append(np.mean(
|
| 133 |
entity_types.append(entity['entity'])
|
| 134 |
-
print(f"{cleaned_entity} ({entity['entity']}): {np.mean(
|
| 135 |
|
| 136 |
word_freq = {text: score for text, score in zip(entity_texts, entity_scores)}
|
| 137 |
|
|
|
|
| 62 |
"entity": entity_type,
|
| 63 |
"start": token['start'],
|
| 64 |
"end": token['end'],
|
| 65 |
+
"scores": [token['score']],
|
| 66 |
"tokens": [token['word']]
|
| 67 |
}
|
| 68 |
else:
|
| 69 |
current_entity['end'] = token['end']
|
| 70 |
+
current_entity['scores'].append(token['score'])
|
| 71 |
current_entity['tokens'].append(token['word'])
|
| 72 |
|
| 73 |
if current_entity is not None:
|
|
|
|
| 129 |
for entity in entities:
|
| 130 |
cleaned_entity = re.sub(r'^\W+', '', ' '.join(entity['tokens']))
|
| 131 |
entity_texts.append(cleaned_entity)
|
| 132 |
+
entity_scores.append(np.mean(entity['scores']))
|
| 133 |
entity_types.append(entity['entity'])
|
| 134 |
+
print(f"{cleaned_entity} ({entity['entity']}): {np.mean(entity['scores'])}")
|
| 135 |
|
| 136 |
word_freq = {text: score for text, score in zip(entity_texts, entity_scores)}
|
| 137 |
|