From 6b6e7337a3418fbb81567c9a4816ff696e10bbcb Mon Sep 17 00:00:00 2001 From: chflame163 <130118553+chflame163@users.noreply.github.com> Date: Thu, 11 Jan 2024 21:30:26 +0800 Subject: [PATCH] optimize debug info and fix a empty string bug --- py/comfy_wordcloud.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/py/comfy_wordcloud.py b/py/comfy_wordcloud.py index 00daf64..100ff52 100644 --- a/py/comfy_wordcloud.py +++ b/py/comfy_wordcloud.py @@ -126,15 +126,19 @@ class ComfyWordCloud: ): # parameter preprocessing - if text == None: + if text == '': text = DEFAULT_TEXT + print(f"# 😺dzNodes: WordCloud: -> text not found, use demo string.") + else: + print(f"# 😺dzNodes: WordCloud: -> get text, total of {len(text)} chars.") freq_dict = WordCloud().process_text(' '.join(jieba.cut(text))) - if not keynote_words == None: + if not keynote_words == '': keynote_list = list(re.split(r'[,,\s*]', keynote_words)) keynote_dict = {keynote_list[i]: keynote_weight + max(freq_dict.values()) for i in range(len(keynote_list))} freq_dict.update(keynote_dict) - print(f"# 😺dzNodes: WordCloud: -> word frequencies dict is {freq_dict}") + + print(f"# 😺dzNodes: WordCloud: -> word frequencies dict generated, include {len(freq_dict)} words.") if not os.path.exists(os.path.normpath(font_path)): print(f"# 😺dzNodes: WordCloud: -> {font_path} font_path is invalid, use default font.")