Skip to content

Commit

Permalink
Polish.
Browse files Browse the repository at this point in the history
  • Loading branch information
jendrikseipp committed May 5, 2024
1 parent 0e486fe commit 4eb74ef
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions rednotebook/gui/clouds.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def _update(self):
word_count_dict,
self.regexes_ignore + self.regexes_special_ignore_words,
self.regexes_include,
self.tags,
{tag for tag, _freq in self.tags},
)

self.link_dict = self.tags + self.words
Expand Down Expand Up @@ -179,20 +179,19 @@ def _get_tags_for_cloud(self, tag_count_dict, ignores):
tags_and_frequencies = [
(tag, freq)
for (tag, freq) in tag_count_dict
if all(not pattern.match(tag) for pattern in ignores)
if not any(pattern.match(tag) for pattern in ignores)
]

tag_display_limit = self.journal.config.read("cloudMaxTags")
return self.select_most_frequent_words(tags_and_frequencies, tag_display_limit)

def _get_words_for_cloud(self, word_count_dict, ignores, includes, tags_count):
tags_set = set(map(lambda tag_count: tag_count[0][1:], tags_count))
def _get_words_for_cloud(self, word_count_dict, ignores, includes, tags):
words_and_frequencies = [
(word, freq)
for (word, freq) in word_count_dict.items()
if (len(word) > 4 or any(pattern.match(word) for pattern in includes))
and all(not pattern.match(word) for pattern in ignores)
and word not in tags_set
and f"#{word}" not in tags
]
return self.select_most_frequent_words(words_and_frequencies, CLOUD_WORDS)

Expand Down

0 comments on commit 4eb74ef

Please sign in to comment.