名称:name' row'未定义
我正在使用Python 3.6.1(空闲)和计算POS_TAG的频率。我的代码是,
import csv
import nltk
with open('data.csv', 'rt') as f:
readerf = csv.reader(f)
from collections import Counter
Counter([j for i,j in pos_tag(row)])
我收到以下错误消息
Traceback (most recent call last):
File "C:/Users/ABRAR/Google Drive/Tourism Project/TouristPython/POS_Tagging.py", line 7, in <module>
Counter([j for i,j in pos_tag(row)])
NameError: name 'row' is not defined
,但是,相同的代码在jupyter(基于Web)中正确运行。 这是我的示例数据
[ab, 吃惊, 放弃, 减弱, ABC, 能力, 有能力的, 洗礼, 盛产, 国外, 突然, 缺席, 绝对, 绝对地, 吸收]
,这是jupyter的快照 代码和答案
I am using the Python 3.6.1(IDLE) and counting the frequency of the pos_tag. My code is
import csv
import nltk
with open('data.csv', 'rt') as f:
readerf = csv.reader(f)
from collections import Counter
Counter([j for i,j in pos_tag(row)])
I am getting the following error message
Traceback (most recent call last):
File "C:/Users/ABRAR/Google Drive/Tourism Project/TouristPython/POS_Tagging.py", line 7, in <module>
Counter([j for i,j in pos_tag(row)])
NameError: name 'row' is not defined
However,the same code run correctly in the jupyter(web based).
Here is my sample data
[ab,
aback,
abandon,
abate,
abc,
ability,
able,
ablution,
abound,
abroad,
abruptly,
absence,
absolute,
absolutely,
absorb]
and here is the snap of jupyter
code and answer
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这将解决您的问题
I think this will solve your problem