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

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”即可;

 

posted @ 2016-06-19 14:49  Mscer  阅读(488)  评论(0编辑  收藏  举报