潜在语义分析Latent semantic analysis note(LSA)原理及代码实现
谦3君3一3发:
终于整出结果了。说说这个代码中的问题:
1. 需要添加import matplotlib.pyplot as plt、import string
2.在控制台里输入pip install matplotlib -i https://link.zhihu.com/target=https%3A//pypi.tuna.tsinghua.edu.cn/simple添加matplotlib库
3.plot和text都是plt下的函数方法,需要改成plt.text()和plt.plot()
4.代码最后需要加一句 plt.show()
5.python2换成python3会有格式制表符和空格对齐问题
6.Python3中print函数需要加“()”输出
7.translate()函数在python3中只有一个参数,需要把python2的两个参数转换为一个参数,转换代码:
trans = str.maketrans({key:None for key in self.ignorechars})
w = w.lower().translate(trans)
|