-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.R
More file actions
49 lines (34 loc) · 1.53 KB
/
server.R
File metadata and controls
49 lines (34 loc) · 1.53 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
# This is the server logic for a Shiny web application.
# You can find out more about building applications with Shiny here:
#
# http://shiny.rstudio.com
#
library(shiny)
require(RCurl)
source("R/capstone.R")
library(RSQLite)
#capstone.loadDataTablesRemote()
shinyServer(function(input, output, session) {
load(url("http://s3.amazonaws.com/giusepperomagnuolo.datascience.capstone/quanteda.unigramDataS.RData"))
load(url("http://s3.amazonaws.com/giusepperomagnuolo.datascience.capstone/quanteda.bigramDataS.RData"))
load(url("http://s3.amazonaws.com/giusepperomagnuolo.datascience.capstone/quanteda.trigramDataS.RData"))
# fetch text from webpage
sentence <- reactive(input$sentence)
# filtering based on widget settings
filteredTerms <- reactive({
# Making this reactive on fetchButton only
input$fetchButton
r <- capstone.predictNextWord(sentence(), unigramData, bigramData, trigramData)
r <- head(r, n = input$max)
r
})
# Output for tabular data
output$commonTable <- renderDataTable({
if (input$fetchButton != 0) {
t <- filteredTerms()
isolate({
t[, .("Next word" = wordsLast, "Kneser-Ney Probability" = pKN, "MLE Probability" = pMLE)]
})
}
})
})