当前位置: 首页 > news >正文

一建 建设网站建设摩托车官网报价表

一建 建设网站,建设摩托车官网报价表,网页设计费多少钱,长沙的科技公司一、说明 在本文我们将看到,在情感分析方面,我们更喜欢哪个库。这取决于很多情况。例如。数据采集。在我们进行分析之前,让我们先看看这两个库是关于什么的。 二、亮相工具库 2.1. 工具库TextBlob介绍: 图像。TextBlob: Simplif…

一、说明

在本文我们将看到,在情感分析方面,我们更喜欢哪个库。这取决于很多情况。例如。数据采集。在我们进行分析之前,让我们先看看这两个库是关于什么的。

二、亮相工具库 

2.1. 工具库TextBlob介绍:

图像。https://textblob.readthedocs.io/en/dev/index.html

图像。TextBlob: Simplified Text Processing — TextBlob 0.16.0 documentation

TextBlob 是一个 python 库,可用于多个自然语言处理 (NLP) 任务,例如:

  • 名词短语提取
  • 词性标记
  • 情绪分析
  • 分类
  • 标记化
  • 单词和短语频率
  • 解析
  • n 元语法
  • 词形变化(复数和单数化)和词形还原
  • 拼写更正

#VADER 图像

2.2. 工具库VADER介绍:

VADER(Valence Aware Dictionary and sEntiment Reasoner)是一种基于词典和规则的情感分析工具,(Lexicon 意味着 NLP 系统的组件,其中包含有关每个单词或单词字符串的语义或语法等信息。例如。“无击球手”,“前进跑”和“巴尔的摩排骨”等是棒球词典的一部分,“边界”,“死亡结束”,“杜斯拉”等是板球词典的一部分。这是根据社交媒体的表达进行训练的。

词典情绪分析输出从 -1 到 1 的极性分数,其中 -1 表示真正的负面情绪,1 表示真正积极的情绪。接近 0 的值表示中性情绪。

三、TextBlob对比VADER:

        TextBlob和VADER之间的关键区别在于VADER专注于社交媒体。因此,VADER 投入了大量精力来识别通常出现在社交媒体上的内容的情绪,例如表情符号、重复单词和标点符号。

现在,我们将在情感分析中比较 VADER 和 TextBlob,因为 VADER 是仅用于情感分析的库。

3.1 步骤:

让我们首先安装这两个库。以下代码片段将帮助我们进行安装。

!pip install textblob
!pip install vaderSentiment

现在,让我们导入库。

#Importing libraries
from textblob import TextBlob
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer

现在,让我们创建函数:

#Define funcitons for VADER and textblobdef vader_score(text):#After using VADER we will get  4 values: pos, compound, neu and neg.#pos:positive, neu:neutral, neg:negative#Here we are only collecting the compound. Why?#Because compound score is computed by summing the valence scores of each word in the lexicon, #adjusted according to the rules, and then normalized to be between -1 (most extreme negative) and +1 (most extreme positive).vader_sentiment = SentimentIntensityAnalyzer()score = vader_sentiment.polarity_scores(text) return score['compound']
def textblob_score(text):#textblob_sentiment.sentiment will give us 2 values: polarity and subjectivity#The polarity score is a float within the range [-1.0, 1.0]. #The subjectivity is a float within the range [0.0, 1.0] where 0.0 is very objective and 1.0 is very subjective.# Here we are interested in polarity, so we are using polarotytextblob_sentiment = TextBlob(text)score = textblob_sentiment.sentiment.polarityreturn score

        让我们看一下每种情绪(积极、消极和中性)的示例。

        让我们创建一个包含 3 个句子的列表,每个句子有一个肯定的、一个否定的和一个中性的句子。所以我们可以看到,VADER和TextBlob在它们上的表现。

#List of sentences with different emotions.
#First sentence is neutral.
#second is positive and 
#third is negative.
text_list = ["This is my first ever post on the internet.", "I am very excited to write this post.", "It's not good to work late hours."]

        现在让我们创建一个 for 循环,它将遍历每个句子,并为我们提供之前创建的 “vader_score” 和 “textblob_score” 函数的输出。

#Here it will iterate through every sentence from the text_list list
#and will output the sentence first and on the next line it will
#print the vader score and in the next line it will print the
#textblob score.
for text in text_list:print(f'sentence: {text} \n VADER sentiment score: {vader_score(text)} \n TextBlob score: {textblob_score(text)}')print("=" * 30)

我们将得到这样的输出。

sentence: This is my first ever post on the internet. VADER sentiment score: 0.0 TextBlob score: 0.25
==============================
sentence: I am very excited to write this post. VADER sentiment score: 0.4005 TextBlob score: 0.48750000000000004
==============================
sentence: It's not good to work late hours. VADER sentiment score: -0.3412 TextBlob score: -0.32499999999999996
==============================

        从上面的单元格中,我们可以得出结论,VADER完美地将第一句话识别为中性句子,而TextBlob离它并不远。然后对于第二句话,VADER给出了正分数,但TextBlob给了我们一个更积极的分数。对于最后一句话,VADER给出的负分比TextBlob更高。

        现在,我们可以说VADER和TextBlob都给出了相似的分数。

        现在,由于它看起来很棒,我们需要对句子进行一些更改以进一步深化我们的研究。例如。我们可以添加表情符号,标点符号,大写,重复等。然后我们将看到哪个表现更好。

        检查标点符号的影响:

#Adding punctuations
text_list = ["This is my first ever post on the internet!", "I am very excited to write this post!", "It's not good to work late hours!"]
sentence: This is my first ever post on the internet! VADER sentiment score: 0.0 TextBlob score: 0.3125
==============================
sentence: I am very excited to write this post! VADER sentiment score: 0.4561 TextBlob score: 0.609375
==============================
sentence: It's not good to work late hours! VADER sentiment score: -0.4015 TextBlob score: -0.3625
==============================

        现在,从上面的单元格中,我们可以说,感叹号确实提高了我们在所有句子中的分数。但是对于我们的中性句子(句子 1),TextBlob 走得更远了。

        检查大写的影响:

#Capitalizing words
text_list = ["This is my FIRST EVER post on the internet!", "I am very EXCITED to write this post!", "It's NOT GOOD to work late hours!"]
sentence: This is my FIRST EVER post on the internet! VADER sentiment score: 0.0 TextBlob score: 0.3125
==============================
sentence: I am very EXCITED to write this post! VADER sentiment score: 0.5744 TextBlob score: 0.609375
==============================
sentence: It's NOT GOOD to work late hours! VADER sentiment score: -0.5007 TextBlob score: -0.3625
==============================

        现在,我们可以说,我们的VADER分数提高了,但TextBlob分数保持不变。为什么会这样?好吧,原因是VADER认为大写版本具有更强的情绪并增加了情绪得分。同时,TextBlob 没有区分单词的大写和小写版本之间的情绪。

        检查重复单词的影响:

text_list = ["This is my VERY VERY FIRST EVER post on the internet!", "I am very very EXCITED to write this post!", "It's NOT NOT NOT GOOD to work late hours!"]
sentence: This is my VERY VERY FIRST EVER post on the internet! VADER sentiment score: 0.0 TextBlob score: 0.40625
==============================
sentence: I am very very EXCITED to write this post! VADER sentiment score: 0.6119 TextBlob score: 0.609375
==============================
sentence: It's NOT NOT NOT GOOD to work late hours! VADER sentiment score: -0.3311 TextBlob score: -0.3625
==============================

        通过重复的单词,我们可以看到VADER分数的明显变化,但这不会影响TextBlob分数。这是为什么呢?简单地说,这是因为VADER认为重复的单词具有更强的情感,而TextBlob没有解释重复的单词。

检查表情符号的影响:

text_list = ["This is my VERY VERY FIRST EVER post on the internet🫡🤔!","I am very very EXCITED to write this post😍😇!", "It's NOT NOT NOT GOOD to work late hours☹️😳!"]
sentence: This is my VERY VERY FIRST EVER post on the internet🫡🤔! VADER sentiment score: 0.0 TextBlob score: 0.40625
==============================
sentence: I am very very EXCITED to write this post😍😇! VADER sentiment score: 0.8749 TextBlob score: 0.609375
==============================
sentence: It's NOT NOT NOT GOOD to work late hours☹️😳! VADER sentiment score: -0.5802 TextBlob score: -0.3625
==============================

我们可以清楚地看到,维德分数正在提高。但是 TextBlob 分数根本没有变化。

四、结论:

根据我们所做的实验,这是否意味着VADER库比TextBlob更好?答案是否定的。但是为什么?因为:

TextBlob 可以做的不仅仅是情绪分类。

VADER-情感分析主要针对基于社交媒体数据的情感分析进行训练。TextBlob 的情况并非如此。

因此,我们不能得出VADER更好或TextBlob更好的结论。每个都有自己的用例。您可以根据问题陈述选择要使用的一个。

哈沙德·帕蒂尔

http://www.yayakq.cn/news/706770/

相关文章:

  • 温州网站优化指导包装设计用什么软件
  • 网站设计和策划的步骤是什么学网站开发如何挣钱
  • 济南手机网站定制费用厦门手机建站
  • 旅游网页有哪些中山seo排名
  • 怎样在国外网站上做宣传专业做网站建设制作服务
  • 清苑建设局网站cmseasy模板
  • 下载学校网站模板下载贵阳网站定制建设开发 首商网
  • 做简单网站代码国外营销型网站
  • 陕西省建设工程协会网站建设网站哪个比较好
  • wordpress开发企业网站基于asp.net网站开发
  • 中济建设有限公司网站v2ray wordpress
  • 自己如何建设企业网站免费公众号编辑器哪个好
  • 好的做彩平图的网站腾讯云可以做网站吗3
  • asp网站伪静态教程网站导航提交入口大全
  • 网站建设一般多少费用电子商务网站软件建设的核心是
  • 南山网站多少钱软件开发在哪能看
  • 福田专业做网站公司wordpress 做大型网站
  • 怎样用自己的服务器做网站局域网视频网站建设
  • 给公司做网站wordpress无法创建目录下
  • 支付建设网站的费用什么科目在百度上做购物网站
  • 购物网站的搜索框用代码怎么做大连云app官方下载
  • 网站备案是否收费标准购物网站设计意义
  • 怎么做百度网站免费的ppt下载网站哪个好
  • 长沙互联网网站建设外贸建站有哪些公司
  • 建设部门电工证查询网站东营建设信息网的网址
  • 网站信息同步电子商务网站建设方案书的总结
  • 建设快卡额度查询网站怎样才能做网站
  • 宣传型网站功能定位wordpress .net版本
  • 知名网站开发企业wordpress修改数据库密码忘记
  • 惠州seo建站手机免费网站制作