小编exp*_*r_x的帖子

使用 countvectorizer() 和 tfidfvectorizer() 对列表的列表进行向量化

所以我有以下标记化的列表:

tokenized_list = [['ALL', 'MY', 'CATS', 'IN', 'A', 'ROW'], ['WHEN', 'MY', 
                   'CAT', 'SITS', 'DOWN', ',', 'SHE', 'LOOKS', 'LIKE', 'A', 
                   'FURBY', 'TOY', '!'], ['THE', CAT', 'FROM', 'OUTER', 
                   'SPACE'], ['SUNSHINE', 'LOVES', 'TO', 'SIT', 
                   'LIKE', 'THIS', 'FOR', 'SOME', 'REASON', '.']]
Run Code Online (Sandbox Code Playgroud)

当我尝试使用 CountVectorizer() 或 TfIdfVectorizer() 对其进行矢量化时

 from sklearn.feature_extraction.text import CountVectorizer
 vectorizer = CountVectorizer()
 print(vectorizer.fit_transform(tokenized_list).todense()) 
 print(vectorizer.vocabulary_)
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

AttributeError: 'list' object has no attribute 'lower'
Run Code Online (Sandbox Code Playgroud)

如果我在vectorizer.fit_transform()函数中放置一个简单的列表,它就可以正常工作。

我该如何消除这个错误?

python nlp pandas scikit-learn countvectorizer

6
推荐指数
1
解决办法
2188
查看次数

Vader 情绪分析:如何对单个单词进行评分?

所以我使用 Vader Sentiment Analyzer 来分析某些客户的反馈。在评估输出时,我看到情绪分析器给了我混合的结果。

For eg: "Again, human interaction needs to have resolutions. Your reps 
        cannot BLAME the system and shrug off being able to help. Let 
        alone blame the system and not know WHY the system makes 
        indiscriminate decisions."

Output: compound: 0.2212 neg: 0.111 neu: 0.756, pos: 0.133
Run Code Online (Sandbox Code Playgroud)

在这种情况下,O/P 应该是负数,但它给出了一个更接近中性到正数的复合分数,这是没有意义的。

我在 AppData\Roaming\nltk_data\sentiment\vader_lexicon.txt 中看到了这个文件,其中包含大多数英语单词的情绪分数。

我只是想知道这些单个词是如何根据 pos neg neu 和复合词给出情感分数的?是否有任何算法/过程来评价它们?

最后,我正在考虑构建自己的情感分析词典以获得更好的结果,但为此我需要知道每个单词是如何分配情感分数的?

nlp nltk python-3.x sentiment-analysis vader

1
推荐指数
1
解决办法
4244
查看次数