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

新词发现的结果质量问题 #24

Closed
3 tasks done
blmoistawinde opened this issue Oct 5, 2020 · 0 comments
Closed
3 tasks done

新词发现的结果质量问题 #24

blmoistawinde opened this issue Oct 5, 2020 · 0 comments

Comments

@blmoistawinde
Copy link
Owner

blmoistawinde commented Oct 5, 2020

描述你想要的功能

一封邮件反馈问题:
image
可见图一中,我们新词发现的期待值为“喜宝”,实际结果也返回了“喜宝”,但却有两个无关项。

image
图二中对新词的识别效果就明显不行了,连“自己”、“没有”、“跳舞”这样的词也判定为新词

两个例子中的共同问题是识别出了不希望出现的结果,即,算法的准确问题。

图二的例子中,所有结果都不是理想的结果,即,算法的召回问题。

可能解决方案

准确问题

要想解决准确问题,只要过滤掉“不好”的结果就可以了。

过滤功能实际上本库已经实现了,可以使用excluding_words参数,在其中设定不想要出现的单词列表/集合等即可。

问题是如何定义“不好”的结果,这里大概可以提供两种设想:

  1. 停用词
  2. 旧词,即词典中的常见单词

如果只是使用停用词,本库现在已经可以完成整个流程:

from harvesttext import HarvestText
from harvesttext.resources import get_baidu_stopwords

ht = HarvestText()
stopwords = get_baidu_stopwords()
text = "这里填入你的文本"
new_words_info = ht.word_discover(para, excluding_words=stopwords)  # 这里过滤了停用词
new_words = new_words_info.index.tolist()

如果要过滤旧词,本库还需要引入外部词典。

召回问题

召回问题,可能可以通过获得更多词语来缓解。这可以通过调整参数来实现,这个函数有这些参数可以调整:

:param max_word_len: 允许被发现的最长的新词长度
:param min_freq: 被发现的新词,在给定文本中需要达到的最低频率
:param min_entropy: 被发现的新词,在给定文本中需要达到的最低左右交叉熵
:param min_aggregation: 被发现的新词,在给定文本中需要达到的最低凝聚度

第一项容易理解,后面三项涉及算法原理,不过简单地说,都是越低,能发现的词就越多,不过太低就会引入更多错误结果,出现上一类问题。

要调参获得更多词语的话,首先要设置auto_param=False,然后,可以在默认参数的基础上往下调,下面的默认的参数:

min_entropy = np.log(length) / 10
min_freq = min(0.00005, 20.0 / length)
min_aggregation = np.sqrt(length) / 15

未来改进计划

  • 将停用词设为默认过滤词

  • 引入外部词典,允许方便地过滤旧词

  • 上面的操作在readme和文档中还不明确,需要完善

blmoistawinde added a commit that referenced this issue Oct 5, 2020
将停用词设为默认过滤词;
完善README和文档
blmoistawinde added a commit that referenced this issue Oct 8, 2020
引入可下载的外部词典,辅助新词发现排除旧词 #24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant