Sentiment Analyzer

遍历 rates collection, 对当中每个评论进行情感分析,并将其存入 rates_sentiments collection 中。

用法

生成分析器实例

from taobao_crawler.analyzer.sentiment_analyzer import SentimentAnalyzer
analyzer = SentimentAnalyzer(db)

SentimentAnalyzer(db) 中的 db 参见 DB

运行情感分析器

analyzer.run()

类属性

class analyzer.sentiment_analyzer.SentimentAnalyzer(db)

Bases: object

遍历 rates collection, 对当中每个评论进行情感分析,并将其存入 rates_sentiments collection 中。插入数据示例: {‘item_id’: ‘561319321061’, ‘rate_id’: NumberLong(“331495062062”), ‘score’: 1.00}

__init__(db)
参数:db – 一个 pymongo.MongoClient.db 的实例
run()

运行分析器,分析每个评论,插入数据库中