标签: sentiment-analysis

给定文本的情感分析

这个主题有很多主题.但我也发布了另一个.所有帖子都可能是进行情绪分析的一种方式,但我发现没办法.

我想实施情绪分析的方法.所以我会要求给我一个方法.在我的研究,我发现,是无论如何使用.我猜贝叶斯算法用于计算正词和负词,并使用词袋计算句子正或负的概率.

这只是用于单词,我想我们也必须进行语言处理.那么有没有更多知识的人呢?如果是的话,你可以引导我使用一些算法及其链接作为参考,以便我可以实现.特别是在我的分析中可以帮助我的任何东西.

您也可以选择我可以使用的语言吗?有人说Java比较耗时,所以他们不建议使用Java.

任何类型的帮助非常感谢.

algorithm sentiment-analysis

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

实现scikit-learn机器学习算法

链接:https://stackoverflow.com/questions/18154278/is-there-a-maximum-size-for-the-nltk-naive-bayes-classifer

我在代码中实现scikit-learn机器学习算法时遇到了麻烦.scikit-learn的作者之一在我上面提到的问题上帮助了我,但我不能完全理解它,因为我原来的问题是关于另一个问题,我认为最好开一个新问题.

此代码正在输入推文并将其文本和情感读入字典.然后它解析每行文本,并将文本添加到一个列表中,并将其情绪添加到另一个列表中(根据上面链接问题中作者的建议).

然而,尽管在链接中使用代码并尽可能地查找API,我想我错过了一些东西.运行下面的代码首先给出了一串用冒号分隔的输出,如下所示:

  (0, 299)  0.270522159585
  (0, 271)  0.32340892262
  (0, 266)  0.361182814311
  : :
  (48, 123) 0.240644787937
Run Code Online (Sandbox Code Playgroud)

其次是:

['negative', 'positive', 'negative', 'negative', 'positive', 'negative', 'negative', 'negative', etc]
Run Code Online (Sandbox Code Playgroud)

然后:

ValueError: empty vocabulary; perhaps the documents only contain stop words
Run Code Online (Sandbox Code Playgroud)

我是以错误的方式分配分类器吗?这是我的代码:

test_file = 'RawTweetDataset/SmallSample.csv'
#test_file = 'RawTweetDataset/Dataset.csv'
sample_tweets = 'SampleTweets/FlumeData2.txt'
csv_file = csv.DictReader(open(test_file, 'rb'), delimiter=',', quotechar='"')

tweetsDict = {}

for line in csv_file:
    tweetsDict.update({(line['SentimentText'],line['Sentiment'])})

tweets = []
labels = []
shortenedText = ""
for (text, sentiment) in tweetsDict.items(): …
Run Code Online (Sandbox Code Playgroud)

python sentiment-analysis scikit-learn

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

使用standford nlp的情绪分析不起作用

我正在尝试使用standford nlp来获取文本的情绪:这是我的代码:

import java.util.Properties;

import edu.stanford.nlp.ling.CoreAnnotations;
import edu.stanford.nlp.pipeline.Annotation;
import edu.stanford.nlp.pipeline.StanfordCoreNLP;
import edu.stanford.nlp.rnn.RNNCoreAnnotations;
import edu.stanford.nlp.sentiment.SentimentCoreAnnotations;
import edu.stanford.nlp.trees.Tree;
import edu.stanford.nlp.util.CoreMap;

public class SentimentAnalyzer {

    public static void main(String[] args) {
        findSentiment("");
    }

    public static void findSentiment(String line) {
        line = "I started taking the little pill about 6 years ago.";
        Properties props = new Properties();
        props.setProperty("annotators", "tokenize, ssplit, parse, sentiment");
        StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
        int mainSentiment = 0;
        if (line != null && line.length() > 0) {
            int longest = 0; …
Run Code Online (Sandbox Code Playgroud)

java stanford-nlp sentiment-analysis

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

在for循环中读取csv文件时出现意外输出

import csv
if __name__ == "__main__":
    words = ["great" , "thanks"]
    with open("data/sentiwordnet.tsv", "r") as f:
        reader = csv.DictReader(f,delimiter='\t')
        for word in xrange(len(words)):
             for row in reader:
                 if row['word_en'] == words[word]:
                    print float(row["positive"])
                    print float(row["negative"])
                    print row["synset"]
Run Code Online (Sandbox Code Playgroud)

结果:

0.75
0.0 
124567
Run Code Online (Sandbox Code Playgroud)

以上结果仅适用于第一个单词,即"伟大".循环在这里结束 - 它不会继续下一个单词.

python csv sentiment-analysis

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

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
查看次数

如何使用机器学习为数据分配标签/分数

我有一个由多行组成的数据框,其中包括推文。我想使用机器学习技术(有监督或无监督)对它们进行分类。由于数据集未标记,我想选择几行(50%)手动标记(+1 pos,-1 neg,0中性),然后使用机器学习将标签分配给其他行。为了做到这一点,我做了如下:

原始数据集

Date                   ID        Tweet                         
01/20/2020           4141    The cat is on the table               
01/20/2020           4142    The sky is blue                       
01/20/2020           53      What a wonderful day                  
...
05/12/2020           532     In this extraordinary circumstance we are together   
05/13/2020           12      It was a very bad decision            
05/22/2020           565     I know you are the best              
Run Code Online (Sandbox Code Playgroud)
  1. 将数据集拆分为 50% 的训练和 50% 的测试。我手动标记了 50% 的数据,如下所示:

    Date                   ID        Tweet                          PosNegNeu
     01/20/2020           4141    The cat is on the table               0
     01/20/2020           4142    The weather is bad today …
    Run Code Online (Sandbox Code Playgroud)

python machine-learning sentiment-analysis pandas

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

包'rjson'的R - twitteR软件包下载失败了

我正在尝试一些数据挖掘并尝试从Twitter检索数据.

当我尝试安装包'twitteR'时,我收到以下警告:

Warning in install.packages :
  download of package ‘rjson’ failed
Run Code Online (Sandbox Code Playgroud)

但它加载了其余的包.然后,当我尝试调用库时:

> library(twitteR)
Loading required package: ROAuth
Loading required package: RCurl
Loading required package: bitops

Attaching package: ‘RCurl’

The following object is masked from ‘package:tm.plugin.webmining’:

    getURL

Loading required package: digest
Error: package ‘rjson’ required by ‘twitteR’ could not be found
Run Code Online (Sandbox Code Playgroud)

如果它最初无法下载'rjson'软件包,这是有道理的.

当我尝试单独安装'rjson'软件包时,我得到一个熟悉的错误:

> install.packages("rjson")
trying URL 'http://cran.rstudio.com/bin/macosx/contrib/3.0/rjson_0.2.13.tgz'
Warning in install.packages :
  cannot open: HTTP status was '404 Not Found'
Error in download.file(url, destfile, method, mode = "wb", ...) : …
Run Code Online (Sandbox Code Playgroud)

twitter r data-mining sentiment-analysis

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

情绪计算的公式是什么

使用情绪评级词典来计算情绪的实际公式是什么.我使用的词典包含-5到5之间的等级.我想计算单个句子的情绪.要么我必须计算句子中所有情绪排名单词的平均值,要么只计算它们.

nlp mining sentiment-analysis

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

tensorflow加载模型给出了不同的预测

我的代码是预测句子的情绪.我训练了一个CNN模型并保存了它.当我加载我的模型并尝试预测句子的情绪时,我对同一个句子有不同的预测.我的代码如下,当我尝试通过调用底部的函数predict_cnn_word2vec来预测sentene时,问题就出现了:

import logging;
import numpy as np; 
import tensorflow as tf;
import sklearn as sk
import re; 
import json
import string;
import math
import os
from sklearn.metrics import recall_score, f1_score, precision_score;



class CNN(object):
def __init__(self,logger):
    self.logger = logger; 


def _weight_variable(self,shape):
    initial = tf.truncated_normal(shape, stddev = 0.1); 
    return tf.Variable(initial);

def _bias_variable(self,shape):
    initial = tf.constant(0.1, shape = shape); 
    return tf.Variable(initial);

def _conv2d(self,x, W, b, strides=1):
    # convolve and relu activation
    x = tf.nn.conv2d(x, W, strides=[1, strides, strides, 1], padding='SAME');
    x = tf.nn.bias_add(x, …
Run Code Online (Sandbox Code Playgroud)

machine-learning sentiment-analysis conv-neural-network tensorflow

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

通常,TF-IDF何时会降低准确性?

我正在使用朴素贝叶斯模型将包含200000条评论的语料库分为正面评论和负面评论,并且我注意到执行TF-IDF实际上会使准确性(在对50000条评论的测试集进行测试时)降低了约2%。因此,我想知道TF-IDF是否对使用的数据或模型有任何潜在的假设,即是否存在因使用它而降低准确性的情况?

tf-idf sentiment-analysis text-classification naivebayes

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

如何使 RandomForestClassifier 更快?

我正在尝试使用具有大约 1M 原始数据的 twitter 情绪数据从kaggle站点实现词袋模型。我已经清理了它,但在最后一部分,当我将特征向量和情绪应用于随机森林分类器时,它花费了很多时间。这是我的代码......

from sklearn.ensemble import RandomForestClassifier
forest = RandomForestClassifier(n_estimators = 100,verbose=3)
forest = forest.fit( train_data_features, train["Sentiment"] )
Run Code Online (Sandbox Code Playgroud)

train_data_features 是 1048575x5000 稀疏矩阵。我尝试将其转换为数组,同时这样做表示内存错误。

我哪里做错了?有人可以建议我一些来源或另一种更快的方法吗?我在机器学习方面绝对是新手,没有那么多编程背景,所以一些指南会适应。

非常感谢你提前

machine-learning python-3.x sentiment-analysis pandas

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

电影评论数据集

我将开始一项关于情绪分析和自然语言处理的研究,并将使用电影评论来进行研究。我在网上搜索了数据集,发现有很多但没有一个完全符合我的需要,其中大多数都只有一堆电影详细信息和标签。我只需要评论家或用户的文字评论以及电影标题或ID,就像您在IMDb或Rotten Tomatoes上找到的那样。网络上是否有类似的东西,或者任何语言的API或库,对我有帮助吗?干杯!

video nlp dataset sentiment-analysis

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

如何修复“没有名为textdata的程序包”错误?

我正在尝试在R中运行情感分析。我已经安装了tidytext,它与所有其他软件包一起位于正确的库中。

但是,当我跑步时

get_sentiments("afinn") 

Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

Error in loadNamespace(name) : there is no package called ‘textdata’
Run Code Online (Sandbox Code Playgroud)

有关如何修复的任何建议?

r sentiment-analysis tidytext

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