-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.R
More file actions
77 lines (68 loc) · 2.44 KB
/
server.R
File metadata and controls
77 lines (68 loc) · 2.44 KB
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
73
74
75
76
77
options(shiny.maxRequestSize=30*1024^2)
library(shiny)
library(data.table)
library(NLP)
library(tm)
#Organize the server side to display
shinyServer(function(input, output) {
output$initialText <- renderText({
originalInput <- input$obs
return(originalInput)
})
#Summary
output$Translated <- renderText({
originalInput <- input$obs
translatedInput <- translatedInput(originalInput)
return(translatedInput)
})
#Summary, again !
output$topGuess <- renderText({
originalInput <- input$obs
translatedInput <- translatedInput(originalInput)
topGuess <- "The word that we believe will appear next in your sentence will show up here :)"
translatedInputSplit <- spliceTranslateInput(originalInput)
wordCounter <- length(translatedInputSplit)
if(wordCounter==1){
topGuess <- wordCounter1(translatedInputSplit)
}
if(wordCounter==2){
topGuess <- wordCounter2(translatedInputSplit)
}
if(wordCounter==3){
topGuess <- wordCounter3(translatedInputSplit)
}
if(wordCounter > 3){
Words_to_Search <- c(translatedInputSplit[wordCounter - 2],
translatedInputSplit[wordCounter - 1],
translatedInputSplit[wordCounter])
topGuess <- wordCounter3(Words_to_Search)
}
return(topGuess)
})
#Display the top observations
output$view <- renderTable({
originalInput <- input$obs
translatedInputSplit <- spliceTranslateInput(originalInput)
wordCounter <- length(translatedInputSplit)
if(wordCounter==1){
topGuess <- wordCounter1(translatedInputSplit)
}
if(wordCounter==2){
topGuess <- wordCounter2(translatedInputSplit)
}
if(wordCounter==3){
topGuess <- wordCounter3(translatedInputSplit)
}
if(wordCounter > 3){
searchWords <- c(translatedInputSplit[wordCounter - 2],
translatedInputSplit[wordCounter - 1],
translatedInputSplit[wordCounter])
topGuess <- wordCounter3(searchWords)
}
if(exists("secondGuess", where = -1)){
secondGuess
}else{
XNgramsTable <- data.frame(Word=NA, Likelihood=NA)
}
})
})