Open jwijffels opened 4 years ago
usefull if you want to build your own training / test dataset
as_fasttext <- function(x, y, label = "__label__"){ if(is.list(y)){ targets <- sapply(y, FUN=function(x){ if(length(x) == 0 || all(is.na(x))){ return(NA_character_) } paste(paste(label, x, sep = ""), collapse = " ") }) }else{ targets <- ifelse(is.na(y), NA_character_, paste(label, y, sep = "")) } x <- ifelse(is.na(targets), x, paste(targets, x, sep = " ")) x }
usefull if you want to build your own training / test dataset