Merge pull request #370 from Jasonyang2014/wordcloud-filter-whitespace

词云过滤空白字符
This commit is contained in:
程序员阿江-Relakkes 2024-08-06 17:11:04 +08:00 committed by GitHub
commit 85727da1d3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 1 deletions

View File

@ -27,7 +27,7 @@ class AsyncWordCloudGenerator:
async def generate_word_frequency_and_cloud(self, data, save_words_prefix): async def generate_word_frequency_and_cloud(self, data, save_words_prefix):
all_text = ' '.join(item['content'] for item in data) all_text = ' '.join(item['content'] for item in data)
words = [word for word in jieba.lcut(all_text) if word not in self.stop_words] words = [word for word in jieba.lcut(all_text) if word not in self.stop_words and len(word.strip()) > 0]
word_freq = Counter(words) word_freq = Counter(words)
# Save word frequency to file # Save word frequency to file