-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcursoslr.R
72 lines (55 loc) · 2.45 KB
/
cursoslr.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#Esse arquivo foi criado para o curso de Revisão Sistemática
# apresentado no LCCV, no ano de 2018 por Randy Quindai
# os slides do curso podem ser encontrados no seguinte endereço
# https://sites.google.com/site/sensornetufal/how-to-s/reviso-sistemtica
# LaCCAN - Laboratório de Computação Científica e Análise Numérica
# Grupo de pesquisa : SensorNet-UFAL
library(bibliometrix)
#lê arquivo .bib
#converte .bib num DataFrame pronto a ser processado pelo R
isi.rawdata <- readFiles("savedrecs.bib")
isi.dfrawdata <- convert2df(isi.rawdata, dbsource = "isi", format = "bibtex")
isi.rawcs <- conceptualStructure(isi.dfrawdata, field = "ID", minDegree = 4, k.max = 5, stemming = FALSE, labelsize = 10)
isi.rawcs <- conceptualStructure(isi.dfrawdata, field = "DE_TM", minDegree = 14, k.max = 5, stemming = FALSE, labelsize = 10)
#para visualizar campos da variavel criada, use $
isi.rawcs$km.res
#---------------------------
library(bibliometrix)
results <- biblioAnalysis(isi.dfrawdata, sep=";")
plot(x = results, k = 10, pause = FALSE)
results
#*************************-Processar pdfs
library(tm)
#lê arquivos .pdf localizados no diretório pasta/
#rodar esse comando no diretório pai de pasta/
files <- list.files("pasta/",pattern = "pdf$")
#definindo uma funcao
rpdf <- readPDF(control = list(text = "-layout"))
#muda diretorio para o diretorio dos arquivos .pdf
setwd("pasta/")
#usa a funcao rpdf
#as variaveis isi.pdf e isi.pdfdtm podem ser exploradas usando $
#verifique e tente extrair algum conteudo
isi.pdf <- Corpus(URISource(files), readerControl = list(reader = rpdf))
isi.pdfdtm <- DocumentTermMatrix(isi.pdf, control=list(removePunctuation = TRUE, stopwords = TRUE, tolower = TRUE, stemming = FALSE, removeNumbers = TRUE))
#trabalhando o Corpus criado para extrair alguma informacao
library(dplyr)
library(ggplot2)
library(tidytext)
isi.pdftidy <- tidy(isi.pdfdtm)
#Analise de sentimento, busca efetuada no texto dos artigos
#explore um pouco essa variavel usando $
isi.pdfsentiment <- isi.pdftidy %>%
inner_join(get_sentiments("bing"), by = c(term ="word"))
isi.pdfsentiment %>%
count(sentiment, term, wt = count) %>%
ungroup() %>%
filter(n >= 200) %>%
mutate(n =ifelse(sentiment == "negative", -n, n))%>%
mutate(term=reorder(term,n)) %>%
ggplot(aes(term, n, fill = sentiment)) +
geom_bar(stat="identity") +
ylab("Analisando o sentimento da amostra") +
coord_flip()
#para mais detalhes sobre cada comando ou biblioteca no r use help("comando")
help("tidytext")