AlGe commited on
Commit
0659cc6
·
verified ·
1 Parent(s): 02f2078

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -106,7 +106,6 @@ def generate_charts(ner_output_bin: dict) -> Tuple[go.Figure, np.ndarray]:
106
 
107
  return fig2, wordcloud_image
108
 
109
-
110
  def generate_wordcloud(entities: List[Dict], color_map: Dict[str, str]) -> np.ndarray:
111
  token_texts = []
112
  token_scores = []
@@ -114,10 +113,11 @@ def generate_wordcloud(entities: List[Dict], color_map: Dict[str, str]) -> np.nd
114
 
115
  for entity in entities:
116
  for token in entity['tokens']:
117
- token_texts.append(token)
 
118
  token_scores.append(entity['score'])
119
  token_types.append(entity['entity'])
120
- print(f"{token} ({entity['entity']}): {entity['score']}")
121
 
122
  # Create a dictionary for word cloud
123
  word_freq = {text: score for text, score in zip(token_texts, token_scores)}
@@ -143,6 +143,7 @@ def generate_wordcloud(entities: List[Dict], color_map: Dict[str, str]) -> np.nd
143
 
144
  return image_array
145
 
 
146
  @spaces.GPU
147
  def all(text: str):
148
  ner_output_bin = process_ner(text, pipe_bin)
 
106
 
107
  return fig2, wordcloud_image
108
 
 
109
  def generate_wordcloud(entities: List[Dict], color_map: Dict[str, str]) -> np.ndarray:
110
  token_texts = []
111
  token_scores = []
 
113
 
114
  for entity in entities:
115
  for token in entity['tokens']:
116
+ cleaned_token = token.lstrip('_')
117
+ token_texts.append(cleaned_token)
118
  token_scores.append(entity['score'])
119
  token_types.append(entity['entity'])
120
+ print(f"{cleaned_token} ({entity['entity']}): {entity['score']}")
121
 
122
  # Create a dictionary for word cloud
123
  word_freq = {text: score for text, score in zip(token_texts, token_scores)}
 
143
 
144
  return image_array
145
 
146
+
147
  @spaces.GPU
148
  def all(text: str):
149
  ner_output_bin = process_ner(text, pipe_bin)