Skip to content

Commit

Permalink
重新生成云图
Browse files Browse the repository at this point in the history
  • Loading branch information
Paper-Dragon committed Oct 29, 2023
1 parent 5dbcce0 commit 72f5592
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,24 @@
from PIL import Image
import numpy as np

MARKDOWN_ROOT_PATH = "./src/note-book"
MARKDOWN_ROOT_PATH = "./src/"

stop_words = ['你', '我', '的', '了', '们']
stop_words = ['你', '我', '的', '了', '们', 'True', 'False', 'Node']

FONT = "./MiSans-Normal.ttf"
OUTPUT_IMG_NAME = "./wordcloud.png"
WORDCLOUD_IMAGE_MASK = "./coding.jpg"
RE_POLICY = (r"^(-|#|\.|\*|:|0-9|_|a-z|A-Z|0|png|the|to|RegionOne|"
r"服务器|配置文件|一个|接下来|软件包|自定义|默认值|字符串|尽可能|是因为|表达式|相当于|客户端|初始化|解决方案|"
r"优先级|运算符|管理员|"
r"True|False|"
r"KiB|MiB|GiB|"
r"Shanghai|Server|Client|Local|Address|Image|Runner|Label|Please|Master|Ctrl|"
r"List|Array|String|Field|Column|Name|Version|Live|Depends|Path|"
r"Creating|Running|Stopped|Applying|Installing|Pulling|Active|"
r"Enable|Optional|Ready|Files|Configure|Configuration|"
r"Pull|Node|None|"
r"User|Users|Default|Value|This|Type|File|Asia|\+)*$")


def word_frequency(directory, key_nums=200):
Expand Down Expand Up @@ -47,8 +58,7 @@ def word_frequency(directory, key_nums=200):

# 统计名词的词频
for word in words:
word = re.sub(
r'^(-|#|\.|\*|:|0-9|_|a-z|A-Z|0|png|the|to|一个|\+)*$', '', word)
word = re.sub(RE_POLICY, '', word)
word = re.sub(r'^assets.*$', '', word)
word = re.sub(r'^[a-z].*$', '', word)
word = re.sub(r'^[A-Z][A-Z][A-Z].*$', '', word)
Expand Down Expand Up @@ -88,7 +98,7 @@ def create_wordlouod(wordcloud_item: dict = {"Shanghai": 30, "Beijing": 40}):
height=768,
max_words=400,
max_font_size=80,
# mask=mask,
# mask=mask,
contour_width=3,
contour_color='steelblue',
font_path=f'{FONT}',
Expand Down
Binary file modified wordcloud.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 72f5592

Please sign in to comment.