コード例 #1
0
ファイル: Pipeline.py プロジェクト: zhuang-li/Weibo
def sentimentExtractor(sentence):
    list = pn.single_review_sentiment_score(sentence)
    if list[0] > list[1]:
        return True
    else:
        return False
コード例 #2
0
ファイル: test.py プロジェクト: timeahead/Chinese-Sentiment
__author__ = 'anchengwu'
#coding=utf-8

import sys
sys.path.append("../../../Preprocessing module")

import pos_neg_senti_dict_feature as pn
import textprocessing as tp

# Load dataset
review = tp.get_excel_data(
    "../Machine learning features/seniment review set/pos_review.xlsx", 1, 1,
    "data")

#test single dataset
print pn.single_review_sentiment_score(
    '买过散装的粽子才来买礼盒的,礼盒很大气,比超市买的100多的还要好,配置也不错,肉的素的都有,刚煮了个蛋黄粽子很不错,米好蛋黄也黄很香,老板态度很好,还想买一份~'
    .decode('utf8'))

#test all dataset
for i in pn.all_review_sentiment_score(pn.sentence_sentiment_score(review)):
    print i
コード例 #3
0
ファイル: Pipeline.py プロジェクト: deathlee/Weibo
def sentimentExtractor(sentence):
    list = pn.single_review_sentiment_score(sentence)
    if list[0] > list[1]:
        return True
    else:
        return False
コード例 #4
0
            # 词性分析
            wordList = pseg.cut(reqParamList[1])

            wordFlagResult = ''

            for words in wordList:

                wordFlagResult += words.word + '$%^' + words.flag + '$%^'

            clientSender.publish('wordFlagResult', reqParamList[0] + '!@#' + wordFlagResult)


        elif item['channel'] == 'sentiments':
            # 情感分析

            sr=pn.single_review_sentiment_score(reqParamList[1].decode('utf8'))
            print sr
            if len(sr) <= 0 :
                continue
            pos=sr[2]
            neg=sr[3]
            if (pos==0 and neg ==0):pos=0.5
            elif  (pos==0 and neg !=0):pos=0.1
            elif (pos!=0 and neg !=0):pos=pos/(pos+neg)
            print pos
            # sentimentsResult += words.word + '$%^' + words.flag + '$%^'

            #基于机器学习的情感分析
            s = []
            s.append(reqParamList[1].decode('utf8'))
コード例 #5
0
__author__ = 'anchengwu'
#coding=utf-8

import sys
sys.path.append("../../../Preprocessing module")

import pos_neg_senti_dict_feature as pn
import textprocessing as tp

# Load dataset
review = tp.get_excel_data("../Machine learning features/seniment review set/pos_review.xlsx", 1, 1, "data")

#test single dataset
print pn.single_review_sentiment_score('买过散装的粽子才来买礼盒的,礼盒很大气,比超市买的100多的还要好,配置也不错,肉的素的都有,刚煮了个蛋黄粽子很不错,米好蛋黄也黄很香,老板态度很好,还想买一份~'.decode('utf8'))

#test all dataset
for i in pn.all_review_sentiment_score(pn.sentence_sentiment_score(review)):
	print i