找到一个句子的观点是积极的还是消极的
to find the opinion of a sentence as positive or negative
我需要找到网站上给出的某些评论的意见。我正在为此使用 sentiwordnet。我首先将包含所有评论的文件发送给 POS Tagger。
tokens=nltk.word_tokenize(line) #tokenization for line in file
tagged=nltk.pos_tag(tokens) #for POSTagging
print tagged
除了将其视为 2 个单独的词之外,是否还有其他准确的标记化方法认为它不如 1 个词好。
现在我必须给标记化的词打正分和负分,然后计算总分。 sentiwordnet 中有这方面的功能吗?请帮忙。
请参阅首先从评论中提取副词和形容词
例如:
import nltk
from nltk.tokenize import sent_tokenize, word_tokenize
import csv
para = "What can I say about this place. The staff of the restaurant is nice and the eggplant is not bad. Apart from that, very uninspired food, lack of atmosphere and too expensive. I am a staunch vegetarian and was sorely dissapointed with the veggie options on the menu. Will be the last time I visit, I recommend others to avoid"
sentense = word_tokenize(para)
word_features = []
for i,j in nltk.pos_tag(sentense):
if j in ['JJ', 'JJR', 'JJS', 'RB', 'RBR', 'RBS']:
word_features.append(i)
rating = 0
for i in word_features:
with open('words.txt', 'rt') as f:
reader = csv.reader(f, delimiter=',')
for row in reader:
if i == row[0]:
print i, row[1]
if row[1] == 'pos':
rating = rating + 1
elif row[1] == 'neg':
rating = rating - 1
print rating
现在你必须有一个外部 csv 文件,其中你应该有正面和负面的词
喜欢:
皱纹,负
皱纹,负片
皱纹,负
巧妙地,pos
杰作,pos
杰作,pos
以上脚本的工作方式如下:
1。读句子
2.提取副词和形容词
3.与 CVS 比较正面和负面的词
4.然后给句子评分
以上脚本的结果是:
nice pos
bad neg
expensive neg
sorely neg
-2
根据您的需要更改结果。
对不起我的英语 :P
我需要找到网站上给出的某些评论的意见。我正在为此使用 sentiwordnet。我首先将包含所有评论的文件发送给 POS Tagger。
tokens=nltk.word_tokenize(line) #tokenization for line in file
tagged=nltk.pos_tag(tokens) #for POSTagging
print tagged
除了将其视为 2 个单独的词之外,是否还有其他准确的标记化方法认为它不如 1 个词好。
现在我必须给标记化的词打正分和负分,然后计算总分。 sentiwordnet 中有这方面的功能吗?请帮忙。
请参阅首先从评论中提取副词和形容词 例如:
import nltk
from nltk.tokenize import sent_tokenize, word_tokenize
import csv
para = "What can I say about this place. The staff of the restaurant is nice and the eggplant is not bad. Apart from that, very uninspired food, lack of atmosphere and too expensive. I am a staunch vegetarian and was sorely dissapointed with the veggie options on the menu. Will be the last time I visit, I recommend others to avoid"
sentense = word_tokenize(para)
word_features = []
for i,j in nltk.pos_tag(sentense):
if j in ['JJ', 'JJR', 'JJS', 'RB', 'RBR', 'RBS']:
word_features.append(i)
rating = 0
for i in word_features:
with open('words.txt', 'rt') as f:
reader = csv.reader(f, delimiter=',')
for row in reader:
if i == row[0]:
print i, row[1]
if row[1] == 'pos':
rating = rating + 1
elif row[1] == 'neg':
rating = rating - 1
print rating
现在你必须有一个外部 csv 文件,其中你应该有正面和负面的词
喜欢: 皱纹,负 皱纹,负片 皱纹,负 巧妙地,pos 杰作,pos 杰作,pos
以上脚本的工作方式如下:
1。读句子 2.提取副词和形容词 3.与 CVS 比较正面和负面的词 4.然后给句子评分
以上脚本的结果是:
nice pos
bad neg
expensive neg
sorely neg
-2
根据您的需要更改结果。 对不起我的英语 :P