-
Notifications
You must be signed in to change notification settings - Fork 0
/
analyzerTexto.R
62 lines (50 loc) · 1.77 KB
/
analyzerTexto.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
carregarTexto <- function(input, output, texto, limiteLinhas){
textoPorParagrafo = ""
textoPorFrase = ""
totalCaracteres <- 0
numLinha <- 0
for(paragrafo in texto)
{
numLinha <- numLinha + 1
totalCaracteres = totalCaracteres + str_length(paragrafo)
textoPorParagrafo <- paste(textoPorParagrafo,
"<p>",
"<b>",numLinha,"</b>:",
paragrafo)
}
textoDividido <- paste(texto,collapse=" ")
frases <- tokens(textoDividido,"sentence")
numFrase <- 0
for(frase in frases[[1]])
{
numFrase <- numFrase + 1
textoPorFrase <- paste(textoPorFrase,
"<p>",
"<b>",numFrase,"</b>:",
frase)
}
output$arquivoInf <- renderUI({
limiteTexto <- ""
if(limiteLinhas > 0 && totalLinhas > limiteLinhas)
{
limiteTexto <- paste("<div style='color: red;'>
ATENÇÃO! Foram selecionadas apenas as primeiras ",
limiteLinhas,
" linhas do arquivo selecionado
</div>")
}
HTML(paste(
"<b>Nome: </b>", input$arquivo$name, "<br>",
"<b>Total de caracteres: </b>", format(round(as.numeric(totalCaracteres), 1), nsmall=0, big.mark="."), "<br>",
"<b>Total de parágrafos/linhas: </b>", format(round(as.numeric(totalLinhas), 1), nsmall=0, big.mark="."), "<br>",
"<b>Total de frases: </b>", format(round(as.numeric(numFrase), 1), nsmall=0, big.mark="."), "<br>",
limiteTexto
))
})
output$arquivoPar <- renderUI({
HTML(paste(textoPorParagrafo))
})
output$arquivoFra <- renderUI({
HTML(paste(textoPorFrase))
})
}