I'm trying to get RKEA to work in R Studio. Here's my current code:
#Imports packages
library(RKEA)
library(tm)
#Creates a corpus of training sentences
data <- c("This is a sentence",
"I am in an office",
"I'm working on a laptop",
"I have a glass of water",
"There is a wooden desk",
"I have an apple for lunch")
data <- as.data.frame(data)
data <- Corpus(VectorSource(data$data))
#Creates a corpus of training keywords
keywords <- c("sentence",
"office",
"working",
"glass",
"wooden",
"apple")
keywords <- as.data.frame(keywords)
keywords <- Corpus(VectorSource(keywords$keywords))
#Creates output file for created model
tmpdir <- tempfile()
dir.create(tmpdir)
model <- file.path(tmpdir, "MyModel")
#Creates RKEA model
createModel(data, keywords, model)
This is mostly modelled after the example given in the RKEA documentation. However, when I run this I get the following error message:
Error in .jcall(km, "V", "saveModel") :
weka.core.WekaException: weka.classifiers.bayes.NaiveBayesSimple: Not enough training instances with class labels (required: 1, provided: 0)!
I think your example sentences are too short as documents. The following modification (primarily to the first sample document) works without error:
data <- c("This is a longer and longer sentence.",
"I am in an office.",
"I'm working on a laptop.",
"I have a glass of water.",
"There is a wooden desk.",
"I have an apple for lunch.")
My guess is that with really short sentences, there aren't enough words that aren't keywords to use in building the model.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With