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

Python 3.4.3 textrank 输出结果不一致 #228

Closed
wangbin opened this issue Feb 5, 2015 · 1 comment
Closed

Python 3.4.3 textrank 输出结果不一致 #228

wangbin opened this issue Feb 5, 2015 · 1 comment

Comments

@wangbin
Copy link
Contributor

wangbin commented Feb 5, 2015

使用的 jieba3k 版本是 0.35.1,运行 textrank.py,输出的结果并不是每次都一致,有时候是 rank 不一致,有时候分词顺序也有变化,例如我第一次运行的结果是:

吉林 1.0
欧亚 0.8784690324620021
置业 0.5570823965909757
实现 0.5251879997483273
收入 0.383001166048965
增资 0.36423044252002496
子公司 0.35188745770765256
商业 0.3088569028054478
全资 0.30580471654796243
城市 0.3047237453874052

运行几遍之后,结果变成了:

吉林 1.1539630353308807
欧亚 1.0
置业 0.642527513089811
实现 0.5934888249011712
收入 0.43792138927840285
增资 0.41376271795291225
子公司 0.4074867291991946
全资 0.35313824901503316
商业 0.3525422431858807
城市 0.35029989962713165

可以看到词的 rank 改变了,而且第二次的结果中“全资”和“商业”这两个词的顺序变化了。

我 Google 到的解释是 Python 3.3 改变了对 字典 的 Key 做 hash 的方法,所以在 textrank.py 第30行对字典遍历的时候顺序可能是不一样的,从而导致后续的计算结果不一致。

我看不太懂算法的论文,所以请教一下这是不是 Bug 啊?

@sing1ee
Copy link
Contributor

sing1ee commented Feb 14, 2015

@wangbin 是的,你说的是一个问题,开始忽略了这个细节。谢谢。很快会fix

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

2 participants