我正在创建Shiny App,目的是输入文本文件,使用udpipe库需要创建wordcloud,annoate等...
我得到"继承(x,"字符")不是真的"在运行应用程序时。问题来自" Annotate" Tab,因为我试图从Server.R文件返回数据表
ui.R代码:
shinyUI(
fluidPage(
##today's date
dateInput("date6", "Date:",
startview = "decade"),
##current time
h2(textOutput("CurrentTime")),
# Application title
titlePanel("UDPipe Text Analysis"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
# Input: for uploading a file ----
fileInput("file1", "Choose Text File"),
# Horizontal line ----
tags$hr(),
##checkbox input
checkboxGroupInput("upos",label = h4("Parts Of Speech to Show:"),
c("Adjective" = "ADJ",
"Propernoun" = "PROPN",
"Adverb" = "ADV",
"Noun" = "NOUN",
"Verb"= "VERB"),
selected = c("ADJ","NOUN","VERB"),
width = '100%'
#choiceNames =
# list(icon("Adjective"), icon("Adverb")),
#choiceValues =
#list("ADJ", "ADV")
)),
mainPanel(
tabsetPanel(type = "tabs",
tabPanel("Overview",h4(p("Who deveoped this App")),
p("This app supports only text files. ", align = "justify"),
h4("Pupropse of this app"),
h4("what precaution to take")
),
tabPanel("Annotate",dataTableOutput('Annotate'))
)
)
server.R code
library(shiny)
# Define server logic required to draw a histogram
shinyServer(function(input, output) {
Dataset <- reactive({
if (is.null(input$file)) { return(NULL) } else
{
Data <- readlines(input$file1)
Data = str_replace_all(Data, "<.*?>", "")
return(Data)
}
})
output$Annotate <- renderDataTable(
{
english_model = udpipe_load_model("./english-ud-2.0-170801.udpipe")
x <- udpipe_annotate(english_model, x = Dataset)
return(x)
}
)
})
我试图在输出$ Annotate变量中返回数据表。但它不能正常工作。
答案 0 :(得分:0)
将您的udpipe_annotate
代码行替换为以下代码。
txt <- as.character(Dataset())
udpipe_annotate(ud_dutch, x = txt, doc_id = seq_along(txt))
如果您的闪亮应用中尚未加载任何文字数据,这将避免您将NULL
传递给udpipe_annotate