我的文本来自一个社交网络,所以你可以想象它的本质,我认为文本是干净的,我能想象到的最小;在执行以下卫生处理之后:
我认为运行时是线性的,我不打算做任何并行化,因为更改可用代码需要大量的工作, 例如,对于大约1000个从~50kb到~150kb的文本,它需要大约
在我的机器上运行时间大约是10分钟。在
有没有更好的方法来输入算法来加快烹饪时间? 代码很简单,就像感伤强度分析器要工作的那样,这里是主要部分
sid = SentimentIntensityAnalyzer()
c.execute("select body, creation_date, group_id from posts where (substring(lower(body) from (%s))=(%s)) and language=\'en\' order by creation _ date DESC (s,s,)")
conn.commit()
if(c.rowcount>0):
dump_fetched = c.fetchall()
textsSql=pd.DataFrame(dump_fetched,columns=['body','created_at', 'group_id'])
del dump_fetched
gc.collect()
texts = textsSql['body'].values
# here, some data manipulation: steps listed above
polarity_ = [sid.polarity_scores(s)['compound'] for s in texts]
/1。你不需要删除停止语,nltk+vader已经这样做了。在
/2。您不需要删除标点符号,因为这会影响维德的极性计算,除了处理开销。所以,继续用标点符号。在
/3.你也应该引入句子标记化,因为它会提高准确性,然后根据句子。例句这里:https://github.com/cjhutto/vaderSentiment/blob/master/vaderSentiment/vaderSentiment.py#L517
/4。极性计算是完全独立的,可以使用一个multiprocessing pool来计算小尺寸,比如10,以提供很好的速度提升。在
polarity_ = [sid.polarity_scores(s)['compound'] for s in texts]
相关问题 更多 >
编程相关推荐