NRCLexicon.py 文件源码

python
阅读 36 收藏 0 点赞 0 评论 0

项目:aueb.twitter.sentiment 作者: nlpaueb 项目源码 文件源码
def score(self,tokens):
        total = 0.0
        #score for unigrams
        for token in tokens:
            total += self.d_unigrams.get(token,0.0)

        #score for bigrams, if bigrams exist
        if len(self.d_bigrams)>0 :
            #list with bigrams of the message
            bigrams_list = Counter(list(bigrams(tokens))).keys()
            for bigram in bigrams_list :
                total += self.d_bigrams.get(bigram,0.0)

        return total

    #compute the number of tokens(words) that appear in the lexicon
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号