Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: 想去掉输出词云中出现的数字和标点符号,有没有方法 #65

Open
liuzj288 opened this issue Oct 9, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@liuzj288
Copy link

liuzj288 commented Oct 9, 2022

image

@he0119
Copy link
Owner

he0119 commented Oct 9, 2022

现在似乎还真没有什么好方法…可以暂时在 stopwords 里加上,但没法过滤全。

@he0119 he0119 added the enhancement New feature or request label Nov 7, 2022
@he0119 he0119 mentioned this issue Nov 18, 2022
@MSDNicrosoft
Copy link
Contributor

MSDNicrosoft commented Jan 24, 2023

你好,我最近也在研究词云,这是目前我能想到的解决方案

import re

# 去除 CQ 码
message = re.sub(r"\[CQ:(.+)]", "", message)

# 去除 QQ 表情包
message = re.sub(r"[(.+)]", "", message)

# 去除实数
message = re.sub(r"^(\-|\+)?\d+(\.\d+)?$", "", message)

# 去除标点符号
# message = re.sub(r"\p{P}|\p{S}", "", message)

标点符号我主观认为可能会影响分词效果,所以我注释了那部分,不知道如何处理。


另外,由于在 Python 标准库中的正则模块不支持表达式使用 \p 的快捷符,所以我使用的是 PyPI 上的 regex,该库与标准库的用法大部分兼容。

- import re
+ import regex as re

目前能解决的问题:

  • 数字(包括整数和浮点数)
  • 中英文标点 (注:影响未知,需研究)
  • CQ 码
  • QQ 表情包

@wei-z-git
Copy link
Contributor

现在似乎还真没有什么好方法…可以暂时在 stopwords 里加上,但没法过滤全。

stopwords是什么,可以设置屏蔽关键词吗,求教!

@he0119
Copy link
Owner

he0119 commented Mar 13, 2023

stopwords是什么,可以设置屏蔽关键词吗,求教!

是的,设置了 stopwords 的词语不会出现在词云中。

@he0119 he0119 changed the title 想去掉输出词云中出现的数字和标点符号,有没有方法 Feature: 想去掉输出词云中出现的数字和标点符号,有没有方法 Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants