AlGe commited on
Commit
0368188
·
verified ·
1 Parent(s): c33b27c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -107,7 +107,10 @@ def generate_charts(ner_output_bin: dict) -> Tuple[go.Figure, np.ndarray]:
107
 
108
  return fig2, wordcloud_image
109
 
110
- def generate_wordcloud(entities: List[Dict], color_map: Dict[str, str]) -> np.ndarray:
 
 
 
111
  token_texts = []
112
  token_scores = []
113
  token_types = []
@@ -128,7 +131,7 @@ def generate_wordcloud(entities: List[Dict], color_map: Dict[str, str]) -> np.nd
128
  entity_type = next((t for t, w in zip(token_types, token_texts) if w == word), None)
129
  return color_map.get(entity_type, "#FFFFFF")
130
 
131
- wordcloud = WordCloud(width=800, height=400, background_color='#121212', color_func=color_func).generate_from_frequencies(word_freq)
132
 
133
  # Convert to image array
134
  plt.figure(figsize=(10, 5))
 
107
 
108
  return fig2, wordcloud_image
109
 
110
+ def generate_wordcloud(entities: List[Dict], color_map: Dict[str, str], image_path: str) -> np.ndarray:
111
+
112
+ mask_image = np.array(Image.open(image_path))
113
+
114
  token_texts = []
115
  token_scores = []
116
  token_types = []
 
131
  entity_type = next((t for t, w in zip(token_types, token_texts) if w == word), None)
132
  return color_map.get(entity_type, "#FFFFFF")
133
 
134
+ wordcloud = WordCloud(width=800, height=400, background_color='#121212', mask=mask_image, color_func=color_func).generate_from_frequencies(word_freq)
135
 
136
  # Convert to image array
137
  plt.figure(figsize=(10, 5))