首页 > 其他 > 详细

cannot import name dispersion_plot----------nltk小bug

时间:2016-06-19 15:34:15      阅读:209      评论:0      收藏:0      [点我收藏+]

nltk.text.Text.dispersion_plot函数bug

  nltk.text.Text.dispersion_plot(self,words) 默认调用nltk.draw.dispersion_plot,进而调用matplotlib完成绘图功能。 但是:检查发现,dispersion_plot位于nltk.draw.dispersion下的dispersion_plot中。 直接调用这个函数会提示:“cannot import name dispersion_plot”  

  解决办法:对nltk安装目录下的text.py进行更改。

  1 进入安装目录: cd python2.7/site-packages/nltk

  2 对此目录下的text.py文件尽心修改,找到函数 dispersion_plot(self,words),

  3 将dispersion_plot(self,words)中的‘from nltk.draw import dispersion_plot ‘  修改为:“from nltk.draw.dispersion import dispersion_plot”即可;

 

cannot import name dispersion_plot----------nltk小bug

原文:http://www.cnblogs.com/Mscer/p/5598061.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!