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
|
@@ -116,7 +117,8 @@ def generate_wordcloud(entities: List[Dict], color_map: Dict[str, str]) -> np.nd
|
|
116 |
|
117 |
for entity in entities:
|
118 |
for token in entity['tokens']:
|
119 |
-
|
|
|
120 |
token_texts.append(cleaned_token)
|
121 |
token_scores.append(entity['score'])
|
122 |
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
|
|
|
117 |
|
118 |
for entity in entities:
|
119 |
for token in entity['tokens']:
|
120 |
+
# Remove any leading non-alphanumeric characters
|
121 |
+
cleaned_token = re.sub(r'^\W+', '', token)
|
122 |
token_texts.append(cleaned_token)
|
123 |
token_scores.append(entity['score'])
|
124 |
token_types.append(entity['entity'])
|