I have written a Scalar function for Vertica to get the polarity. Though it produces the correct output for one row input, but for inputs more than one row in length, I get the following error:
ERROR: User-defined Scalar Function <function_name> produced fewer output rows (1) than input rows (18)
The code is as follows:
Code: Select all
library("tm", lib.loc = "<path_to_lib_directory>")
library("slam", lib.loc = "<path_to_lib_directory>")
library("Rstem", lib.loc = "<path_to_lib_directory>")
library("sentiment", lib.loc = "<path_to_lib_directory>")
getSenti <- function(comment) {
pol <- classify_polarity(comment);
pol[[1,4]]
}
getSentiFactory <- function() {
list (
name = getSenti,
udxtype = c("scalar"),
intype = c("varchar"),
outtype = c("varchar")
)
}
Thanks,
EG