Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,6 +12,7 @@ import spaces
|
|
| 12 |
import torch
|
| 13 |
import os
|
| 14 |
import io
|
|
|
|
| 15 |
import colorsys
|
| 16 |
|
| 17 |
import numpy as np
|
|
@@ -113,7 +114,8 @@ def generate_wordcloud(entities: List[Dict], color_map: Dict[str, str]) -> np.nd
|
|
| 113 |
|
| 114 |
for entity in entities:
|
| 115 |
for token in entity['tokens']:
|
| 116 |
-
|
|
|
|
| 117 |
token_texts.append(cleaned_token)
|
| 118 |
token_scores.append(entity['score'])
|
| 119 |
token_types.append(entity['entity'])
|
|
|
|
| 12 |
import torch
|
| 13 |
import os
|
| 14 |
import io
|
| 15 |
+
import re
|
| 16 |
import colorsys
|
| 17 |
|
| 18 |
import numpy as np
|
|
|
|
| 114 |
|
| 115 |
for entity in entities:
|
| 116 |
for token in entity['tokens']:
|
| 117 |
+
# Remove any leading non-alphanumeric characters
|
| 118 |
+
cleaned_token = re.sub(r'^\W+', '', token)
|
| 119 |
token_texts.append(cleaned_token)
|
| 120 |
token_scores.append(entity['score'])
|
| 121 |
token_types.append(entity['entity'])
|