Neste trabalho, usamos o dicionário léxico OpLexicon:

Souza, M.; Vieira, R. Sentiment Analysis on Twitter Data for Portuguese Language. 10th International Conference Computational Processing of the Portuguese Language, 2012. [pdf] [bib]

Souza, M.; Vieira, R.; Busetti, D.; Chishman, R. e Alves, I. M. Construction of a Portuguese Opinion Lexicon from multiple resources. 8th Brazilian Symposium in Information and Human Language Technology, 2011. [pdf] [bib]

http://ontolp.inf.pucrs.br/Recursos/downloads-OpLexicon.php


In [1]:
library(readr)
library(dplyr)
library(stringr)
library(wordcloud)
library(tidytext)
library(tidyRSS)


Attaching package: ‘dplyr’

The following objects are masked from ‘package:stats’:

    filter, lag

The following objects are masked from ‘package:base’:

    intersect, setdiff, setequal, union

Loading required package: RColorBrewer

In [2]:
oplexicon <- read_csv('oplexicon_v3.0/lexico_v3.0.txt', col_names = c('word', 'type', 'weight', 'other'), col_types = 
  cols(
    word = col_character(),
    type = col_character(),
    weight = col_integer(), 
    other = col_character()
  ))
head(oplexicon)


wordtypeweightother
=[ emot-1 A
=@ emot-1 A
=p emot-1 A
=P emot-1 A
=x emot-1 A
=d emot 1 A

In [3]:
stopwords <- read_csv('portuguese-stopwords.txt', col_names = 'word')


Parsed with column specification:
cols(
  word = col_character()
)

In [4]:
feed <- tidyfeed("https://oglobo.globo.com/rss.xml?completo=true")

In [5]:
rss_t <- feed %>%
    unnest_tokens(word,item_title) %>%
    anti_join(stopwords,by="word")

In [6]:
sentimentoFeed <- rss_t %>%
    inner_join(oplexicon) %>%
    group_by(item_link) %>%
    summarize(peso = sum(weight, na.rm = TRUE))
sentimentoFeed


Joining, by = "word"
item_linkpeso
https://oglobo.globo.com/brasil/pf-suspeita-que-blairo-tenha-apagado-remotamente-mensagens-de-celular-apreendido-22374025-3
https://oglobo.globo.com/cultura/filmes/agnes-varda-manda-boneco-de-papelao-para-foto-anual-do-oscar-22373932 0
https://oglobo.globo.com/economia/em-encontro-com-presidente-do-bc-maia-negocia-agenda-pos-previdencia-22374103 0
https://oglobo.globo.com/economia/medico-bilionario-quer-comprar-los-angeles-times-diz-fonte-22374051 0
https://oglobo.globo.com/mundo/al-qaeda-lanca-revista-feminina-para-esposas-de-militantes-extremistas-22374020 -1
https://oglobo.globo.com/mundo/conheca-forca-politica-de-kim-yo-jong-irma-do-lider-da-coreia-do-norte-22373854 -1
https://oglobo.globo.com/rio/plano-integrado-de-seguranca-sofre-com-desencontro-entre-autoridades-22373607 -1

In [ ]: