-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.R
56 lines (49 loc) · 1.1 KB
/
app.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
require(shiny)
source("Prediction.R")
#for the user input
ui<-fluidPage(
titlePanel("Please Enter the Question"),
sidebarLayout(
sidebarPanel(
textInput("a","Question Title"),
textAreaInput("b","Question Body","",height=200),
actionButton("submit","Submit")
)
,
mainPanel(
textOutput("tag"),
textOutput("simques")
)
))
#serve the output variable in main panel
server <- function(input,output){
fetchtag <-eventReactive(input$submit,prediction(input$a,input$b))
output$tag<-renderText({input$submit
pos <- fetchtag()
if (typeof(pos) == "character")
{
paste(pos)
}
else
{
paste("Tag Predicted:",TopFrequencies[pos, 1])
}
})
getsimilarques <-eventReactive(input$submit,fetch_sim(TopFrequencies[fetchtag(), 1]))
output$simques<-renderText({input$submit
result<-getsimilarques()
if (typeof(result)=="list")
{
temp<-""
for (i in 1:5){
temp<-paste(temp, i,")",result$title[i], ".",sep =' ')
}
paste("Similar Questions: ",temp)
}
else
{
paste("Similar Questions: No similar Questions Found")
}
})
}
shinyApp(ui,server)