# install.packages("pdftools")
# install.packages("tm")
# install.packages("wordcloud")
library(pdftools)
library(tm)
library(wordcloud)
reader <- readPDF()
dream <- reader(list(uri = "https://www.palmares.gov.br/sites/000/2/download/mlk2.pdf"), language = "pt")
dream <- dream$content
dream <- paste(dream, collapse = " ")
dream <- Corpus(VectorSource(dream))
dream <- tm_map(dream, tolower)
dream <- tm_map(dream, removePunctuation)
dream <- tm_map(dream, removeNumbers)
dream <- tm_map(dream, removeWords, stopwords('portuguese'))
dream <- tm_map(dream, stripWhitespace)
min.freq = 3
frequency_dream <- as.matrix(TermDocumentMatrix(dream))
frequency_dream <- sort(rowSums(frequency_dream), decreasing=TRUE)
wordcloud (dream, min.freq=min.freq, max.words=Inf, random.order=FALSE, rot.per=0.5, colors=brewer.pal(8, "Dark2"))
A nuvem acima apresenta as 64 palavras mais frequentes no discurso “Eu tenho um sonho” de Martin Luther King Jr (considerando as palavras com frequência maior ou igua a 3).
barplot(subset(frequency_dream, frequency_dream > 4), las=2, col=rainbow(10))
Como podemos observar no gráfico de barras acima, a palavra mais frequente no discurso é liberdade, com um total de 22 ocorrências.
library(httr)
library(jsonlite)
library(dplyr)
library(tm)
library(dplyr)
search_recent_tweets <- function(bearer_token, query, max_results, lang=NULL) {
headers <- c(`Authorization` = sprintf('Bearer %s', bearer_token))
if (max_results < 10) {
return("max_results deve ser maior ou igual a 10.")
}
result <- data.frame()
first_try <- TRUE
while (nrow(result) < max_results) {
if (first_try) {
params <- list(query = query, tweet.fields = 'lang', max_results=100)
first_try <- FALSE
} else {
params <- list(query = query, tweet.fields = 'lang', max_results=100, pagination_token = tail(tweets, 1)$meta.next_token)
}
response <- httr::GET(url = 'https://api.twitter.com/2/tweets/search/recent', httr::add_headers(.headers = headers), query = params)
obj <- httr::content(response, as = "text")
tweets <- fromJSON(obj, flatten = TRUE) %>% as.data.frame
if (!("meta.result_count" %in% colnames(tweets))) {
return(result)
}
if (!is.null(lang)) {
tweets <- tweets%>%filter(data.lang==lang)
}
result <- bind_rows(result, tweets)
}
return(result[1:max_results,])
}
query <- "#Brasil"
max_results <- 1000
tweets <- search_recent_tweets(bearer_token, query, max_results, lang='pt')
tweets$data.text <- gsub("@\\w+ *", "", tweets$data.text)
tweets$data.text <- gsub("(f|ht)(tp)(s?)(://)(.*)[.][a-z]{2,6}", "", tweets$data.text)
tweets$data.text <- sapply(tweets$data.text, function(row) iconv(row,from="UTF-8",to="ASCII//TRANSLIT"))
tweets$data.text <- sapply(tweets$data.text, function(row) iconv(row, "latin1", "ASCII", sub=""))
tweets_t <- paste(tweets$data.text, collapse = " ")
tweets_t <- Corpus(VectorSource(tweets_t))
tweets_t <- tm_map(tweets_t, tolower)
tweets_t <- tm_map(tweets_t, removePunctuation)
tweets_t <- tm_map(tweets_t, removeNumbers)
tweets_t <- tm_map(tweets_t, removeWords, stopwords('portuguese'))
tweets_t <- tm_map(tweets_t, stripWhitespace)
min.freq = 20
frequency <- as.matrix(TermDocumentMatrix(tweets_t))
frequency <- sort(rowSums(frequency), decreasing=TRUE)
wordcloud (tweets_t, min.freq=min.freq, max.words=Inf, random.order=FALSE, rot.per=0.5, colors=brewer.pal(8, "Dark2"))
A nuvem acima apresenta as 65 palavras mais frequentes em 1000 tweets publicados nos últimos 7 dias. (considerando as palavras com frequência maior ou igua a 20). A palavra mais frequente é brasil, com um total de 737 ocorrências, seguida por defendo, com um total de 336 ocorrências. A palavra lula apresenta 32 ocorrências. (Obs.: a definição da variável bearer_token, por uma questão de privacidade, foi ocultada.)
# install.packages("syuzhet")
library(syuzhet)
tweets_s <- tweets$data.text
sentimento <- colSums(get_nrc_sentiment(tweets_s))
barplot(sentimento,las=2,col=rainbow(10),ylab= "Quantidade",main= "Pontuação de Sentimentos para os Tweets #brasil")
Dos 1000 obtidos, foi possível realizar a análise de sentimento em 318 deles. Destes, 81 foram classificados como positivos (25.4716981%) e 51 foram classificados como negativos (16.0377358%).
\[p_{(i,j)}= \begin{cases} 0, & \text{se} \ p_{(i,j)} \ \text{não é ponto de entrega ou ponto de origem/retorno} \\ n, & \text{se}\ p_{(i,j)} \ \text{é ponto de entrega e} \ n > 0\\ -1, & \text{se}\ p_{(i,j)} \ \text{é ponto de origem/retorno} \end{cases}\]
\[ P^k_{ij} = \frac{\tau^\alpha_{ij}\eta^\beta_{ij}}{\sum_{j \in N^k_i}\tau^\alpha_{ij}\eta^\beta_{ij}} \] \[\begin{equation} P_e = \{v_1, v_2, \dots, v_{k}\} \end{equation} \] Sendo \(v_i = p_{(x,y)}\), \(\forall i,j, v_i \neq v_j\) e \(i,j <= k\), sendo \(k\) a quantidade de elementos do conjunto \(P_e\), ou seja \(|P_e|\). \[\begin{equation} P_o = \{p_{(x, y)}\} \end{equation}\] Sendo \(p_{(x, y)} = R\).
A linguagem verificada pelo algoritmo \(A\) é: \[L = \{x \in \{0,1\}^* : \text{existe } y \in \{0,1\}^* \text{tal que } A(x, y) = 1\}\]
\[\begin{equation} d_{(p_{(i,j)}, p_{(k,l)})} = \sqrt{(k-i)^2 + (l-j)^2} \end{equation}\]
\[\begin{equation} custo(s, R) = d(R, s_1)+ d(s_i, R)+\sum_{n=1}^{i - 1}d(s_n, s_{n+1}) \end{equation}\]
Analisando a parte inicial da inequação, considerando \(n \ge n_0 \ge |a| + 1\), temos:
\[n + a \ge \frac{1}{|-2 + a|}n\]
Como sabemos que \(a < 0\), podemos reescrever a inequação acima de formar a explicitar seu valor negativo e utilizando seu valor absoluto nas operações subsequentes:
\(n - a \ge \frac{1}{|-2 - a|}n\)
\(n - a \ge \frac{1}{|-1(2 + a)|}n\)
\(n - a \ge \frac{1}{|-1||(2 + a)|}n\)
\(n - a \ge \frac{1}{2 + a}n\)
\((n - a)(2 + a) \ge n\)
\(2n + an -2a - a^2 - n \ge 0\)
\(n + an -a -a - a^2 \ge 0\)
\(n(1 + a)-a -a(1 + a) \ge 0\)
\((n - a)(1 + a)-a \ge 0\)
\((n - a)(1 + a) \ge a\)
# install.packages("DT")
library(DT)
dt_dream <- as.data.frame(frequency_dream)
dt_dream <- cbind("Palavra" = rownames(dt_dream), dt_dream)
rownames(dt_dream) <- NULL
colnames(dt_dream) <- c("Palavra", "Frequência")
datatable(dt_dream, caption="Palavras mais frequentes no discurso “Eu tenho um sonho” de Martin Luther King Jr")
# install.packages("DT")
datatable(airquality, caption="Daily air quality measurements in New York, May to September 1973.")
Software effort estimation using machine learning techniques with robust confidence intervals(Braga, Oliveira, and Meira 2007).
Participatory surveillance based on crowdsourcing during the Rio 2016 Olympic games using the guardians of health platform: descriptive study(Neto et al. 2020).
fastRTM: um ambiente integrado para desenvolvimento rápido da migração reversa no tempo (RTM) em plataformas FPGA de alto desempenho(Medeiros 2013).
Determinação do comportamento de bovinos de leite a pasto baseado em dados de localização GPS e ambientais(Nascimento Bezerra et al. 2021).
Técnica Biospeckle Laser para avaliação de danos mecânicos em mangas Tommy(Santana et al. 2021).