Skip to content

Commit

Permalink
feat(thematos-models): add image collage feature for word clouds in T…
Browse files Browse the repository at this point in the history
…opicModel
  • Loading branch information
entelecheia committed Aug 12, 2023
1 parent d88d76e commit 6953b9f
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/thematos/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,31 @@ def generate_wordclouds(
):
wc_args = self.wc_args
wc = wc_args.wc
images = []
for topic_id in range(self.num_topics):
output_file = self.topic_wordcloud_file_format.format(topic_id=topic_id)
wc.generate_from_frequencies(
img = wc.generate_from_frequencies(
self.get_topic_words(topic_id, top_n=wc_args.top_n),
output_file=output_file,
)
images.append(img)

if wc_args.make_collage:
output_dir = self.output_dir / "wordcloud_collage"
output_file_format = self.model_id + "_wordcloud_{page_num:02d}.png"
HyFI.make_subplot_pages_from_images(
images,
num_images_per_page=wc_args.num_images_per_page,
num_cols=wc_args.num_cols,
num_rows=wc_args.num_rows,
output_dir=output_dir,
output_file_format=output_file_format,
titles=wc_args.titles,
title_fontsize=wc_args.title_fontsize,
title_color=wc_args.title_color,
figsize=wc_args.figsize,
width_multiple=wc_args.width_multiple,
height_multiple=wc_args.height_multiple,
dpi=wc_args.dpi,
verbose=self.verbose,
)

0 comments on commit 6953b9f

Please sign in to comment.