推特网页语言怎么设置成汉语(推特在哪儿设置语言)
概述
对于这个项目,我们在2019年5月28-29日通过爬虫来使用Twitter的原始数据。此外,数据是CSV格式。
它涉及两个主题,一个是包含关键字“Joko Widodo”的Joko Widodo的数据,另一个是带有关键字“Prabowo Subianto”的Prabowo Subianto的数据。其中包括几个变量和信息,以确定用户情绪。实际上,数据有16个变量或属性和1000多个观察值。表1列出了一些变量。
# 导入库librarylibrary# 加载Joko Widodo的数据data.jokowi.df = read.csvsenti.jokowi = read.csv# 加载Prabowo Subianto的数据data.prabowo.df = read.csvsenti.prabowo = read.csv
数据可视化
数据探索旨在从Twitter数据中获取任何信息。应该指出的是,数据已经进行了文本预处理。我们对那些被认为是很有趣的变量进行探索。。
# TWEETS的条形图-JOKO WIDODOdata.jokowi.df$created = ymd_hms# 另一种制作“date”和“hour”变量的方法data.jokowi.df$date = datedata.jokowi.df$hour = hour# 日期2019-05-29data.jokowi.date1 = subsetdata.hour.date1 = data.frame)colnames = c# 创建数据可视化ggplot+ geom_bar), stat = 'identity', alpha = 0.75, show.legend = FALSE)+ geom_hline, col = I, size = 1)+ geom_text), 'Tweets per hour'), x = 8, y = mean+20), hjust = 'left', size = 4)+ labs+ xlab+ ylab+ scale_fill_brewer+ theme_bw# TWEETS的条形图-PRABOWO SUBIANTOdata.prabowo.df$created = ymd_hms# 另一种制作“date”和“hour”变量的方法data.prabowo.df$date = datedata.prabowo.df$hour = hour# 日期2019-05-28data.prabowo.date1 = subsetdata.hour.date1 = data.frame)colnames = c# 日期 2019-05-29data.prabowo.date2 = subsetdata.hour.date2 = data.frame)colnames = cdata.hour.date3 = rbinddata.hour.date3$Date = c), rep))data.hour.date3$Labels = cdata.hour.date3$Hour = as.characterdata.hour.date3$Hour = as.numeric# 数据预处理for ) { if { data.hour.date3[i,'Hour'] = '' } if { data.hour.date3[i,'Hour'] = data.hour.date3[i,'Hour'] }}data.hour.date3$Hour = as.factor# 数据可视化ggplot+ geom_bar, stat = 'identity', alpha = 0.75, show.legend = TRUE)+ geom_hline, col = I, size = 1)+ geom_text), 'Tweets per hour'), x = 5, y = mean+6), hjust = 'left', size = 3.8)+ scale_x_discrete+ labs+ xlab+ ylab+ ylim)+ theme_bw+ theme)+ scale_fill_brewer
根据图1,我们可以得出结论,通过数据抓取得到的tweet数量并不相似,即使在同一日期。
例如,在图1中,从视觉上看,对于关键字为“Joko Widodo”的推文,仅在2019年5月28日03:00–17:00 WIB期间获得。而在图1中,我们得出的结论是,在2019年5月28日至29日12:00-23:59 WIB和00:00-15:00 WIB期间获得的关键词为“Prabowo Subianto”的推文。
# 2019-05-28的推特ggplot+ geom_bar), stat = 'identity', alpha = 0.75, show.legend = FALSE)+ geom_hline, col = I, size = 1)+ geom_text), 'Tweets per hour'), x = 6.5, y = mean+5), hjust = 'left', size = 4)+ labs+ xlab+ ylab+ ylim)+ theme_bw+ scale_fill_brewer# 2019-05-29的推特ggplot+ geom_bar), stat = 'identity', alpha = 0.75, show.legend = FALSE)+ geom_hline, col = I, size = 1)+ geom_text), 'Tweets per hour'), x = 1, y = mean+6), hjust = 'left', size = 4)+ labs+ xlab+ ylab+ ylim)+ theme_bw+ scale_fill_brewer
根据图2,我们得到了使用关键字“Joko Widodo”和“Prabowo Subianto”的用户之间的显著差异。关键词为“Joko Widodo”的tweet在某个特定时间谈论Joko Widodo往往非常激烈,08:00 WIB的tweet数量蕞多。它有348条推文。然而,在2019年5月28日至29日期间,关键词为“Prabowo Subianto”的推文往往会不断地谈论Prabowo Subianto。2019年5月28日至29日,每小时上传关键词为“Prabowo Subianto”的推文平均为36条。
# JOKO WIDODOdf.score.1 = subset)colnames = c# Data vizggplot+ geom_density, alpha = 0.75)+ xlim)+ labs+ xlab+ ylab+ theme_bw+ scale_fill_brewer+ theme)# PRABOWO SUBIANTOdf.score.2 = subset)colnames = cggplot+ geom_density, alpha = 0.75)+ xlim)+ labs+ xlab+ ylab+ theme_bw+ scale_fill_brewer+ theme)
图3是2019年5月28日至29日以“Joko Widodo”和“Prabowo Subianto”为关键词的多条推文的条形图。由图3可以得出,Twitter用户在19:00-23:59 WIB上谈论Prabowo Subianto的频率较低。这是由于印尼人的休息时间造成的。然而,这些带有主题的推文总是在午夜更新,因为有的用户居住在国外,有的用户仍然活跃。然后,用户在04:00 WIB开始活动,在07:00 WIB达到高峰,然后下降,直到12:00 WIB再次上升。
# JOKO WIDODOdf.senti.score.1 = data.frame)colnames = c# 数据预处理df.senti.score.1$Score = as.characterdf.senti.score.1$Score = as.numericScore1 = df.senti.score.1$Scoresignfor ) { sign.row = sign for ) { df.senti.score.1[i,j] = df.senti.score.1[i,j] * sign.row }}df.senti.score.1$Label = c])df.senti.score.1$Sentiment = ifelsedf.senti.score.1$Score1 = Score1# 数据可视化ggplot+ geom_bar, stat = 'identity', show.legend = FALSE)+ # 积极情感 geom_hline,'Freq'])), col = I, size = 1)+ geom_text,'Freq'])))), x = 10, y = mean,'Freq']))+30), hjust = 'right', size = 4)+ # 消极情感 geom_hline,'Freq']), col = I, size = 1)+ geom_text,'Freq'])))), x = 5, y = mean,'Freq'])-15), hjust = 'left', size = 4)+ labs+ xlab+ scale_x_discrete+ theme_bw+ scale_fill_brewer# PRABOWO SUBIANTOdf.senti.score.2 = data.frame)colnames = c# 数据预处理df.senti.score.2$Score = as.characterdf.senti.score.2$Score = as.numericScore2 = df.senti.score.2$Scoresignfor ) { sign.row = sign for ) { df.senti.score.2[i,j] = df.senti.score.2[i,j] * sign.row }}df.senti.score.2$Label = c])df.senti.score.2$Sentiment = ifelsedf.senti.score.2$Score1 = Score2# 数据可视化ggplot+ geom_bar, stat = 'identity', show.legend = FALSE)+ # 积极情感 geom_hline,'Freq'])), col = I, size = 1)+ geom_text,'Freq'])))), x = 22, y = mean,'Freq']))+20), hjust = 'right', size = 4)+ # 消极情感 geom_hline,'Freq']), col = I, size = 1)+ geom_text,'Freq'])))), x = 9, y = mean,'Freq'])-10), hjust = 'left', size = 4)+ labs+ xlab+ scale_x_discrete+ theme_bw+ scale_fill_brewer
图4是包含关键字“Joko Widodo”和“Prabowo Subianto”的情感得分密度图。tweets的得分是由组成tweets的词根的平均得分得到的。因此,它的分数是针对每个词根给出的,其值介于-10到10之间。如果分数越小,那么微博中的负面情绪就越多,反之亦然。根据图4,可以得出结论,包含关键字“Joko Widodo”的推文的负面情绪在-10到-1之间,中间得分为-4。它也适用于积极的情绪。根据图4中的密度图,我们发现积极情绪的得分具有相当小的方差。因此,我们得出结论,对包含关键词“Joko Widodo”的微博的积极情绪并不是太多样化。
图4显示了包含关键字“Prabowo Subianto”的情感得分密度图。它与图4不同,因为图4上的负面情绪在-8到-1之间。这意味着tweets没有太多负面情绪。此外,负面情绪得分的分布在4和1之间有两个峰值。然而,积极情绪从1到10不等。与图4相比,图4的积极情绪具有较高的方差,在3和10范围内有两个峰值。这表明,包含关键词“Prabowo Subianto”的微博具有很高的积极情绪。
# JOKO WIDODOdf.senti.3 = as.data.frame)colnames = c# 数据预处理df.pie.1 = df.senti.3df.pie.1$Prop = df.pie.1$Freq/sumdf.pie.1 = df.pie.1 %>% arrange) %>% mutate - 0.5*Prop)# 数据可视化ggplot)+ geom_bar+ coord_polar+ geom_text, color = 'white', fontface = 'italic', size = 4)+ labs+ xlim)+ theme_void+ scale_fill_brewer+ theme, legend.position = 'right')# PRABOWO SUBIANTOdf.senti.4 = as.data.frame)colnames = c# 数据预处理df.pie.2 = df.senti.4df.pie.2$Prop = df.pie.2$Freq/sumdf.pie.2 = df.pie.2 %>% arrange) %>% mutate - 0.5*Prop)# 数据可视化ggplot)+ geom_bar+ coord_polar+ geom_text, color = 'white', fontface = 'italic', size = 4)+ labs+ xlim)+ theme_void+ scale_fill_brewer+ theme, legend.position = 'right')
图5是推特的情绪得分汇总,这些微博被分为负面情绪、中性情绪和积极情绪。消极情绪是指得分低于零的情绪,中性是指分数等于零的情绪,积极情绪得分大于零。从图5可以看出,关键字为“Joko Widodo”的微博的负面情绪百分比低于关键字为“Prabowo Subianto”的tweet。有6.3%的差异。研究还发现,与关键词为Prabowo Subianto的微博相比,包含关键词“Joko Widodo”的微博具有更高的中性情绪和积极情绪。通过piechart的研究发现,与关键字为“Prabowo Subianto”的tweet相比,带有关键字“Joko Widodo”的tweet倾向于拥有更高比例的积极情绪。但是通过密度图发现,积极和消极情绪得分的分布表明,与“Joko Widodo”相比,包含关键字“Prabowo Subianto”的微博往往具有更高的情绪得分。它必须进行进一步的分析。
图6显示了用户在2019年5月28-29日经常上传的tweet中的术语或单词。通过这个WordCloud可视化,可以找到热门话题,这些话题都是针对关键词进行讨论的。对于包含关键词“Joko Widodo”的tweet,我们发现术语“tuang”、“petisi”、“negara”、“aman”和“nusantara”是前五名,每个tweet出现的次数蕞多。然而,包含关键词“Joko Widodo”的tweet发现,“Prabowo”、“Subianto”、“kriminalisasi”、“selamat”和“dubai”是每个tweet中出现次数蕞多的前五个词。这间接地显示了以关键字“Prabowo Subianto”上传的tweet的模式,即:几乎可以肯定的是,每个上传的tweet都直接包含“Prabowo Subianto”的名称,而不是通过提及。这是因为,在文本预处理中,提到已被删除。
参考引用
[1] K. Borau, C. Ullrich, J. Feng, R. Shen. Microblogging for Language Learning: Using Twitter to Train Communicative and Cultural Competence , Advances in Web-Based Learning — ICWL 2009, 8th International Conference, Aachen, Germany, August 19–21, 2009.
海外精品引流脚本–最强海外引流
唯一TG:https://t.me/Facebook181818
更多海外引流脚本方案
如果你需要脚本演示、部署咨询或海外获客方案,可以通过下面入口继续查看。
