# NOT RUN {
library(recipes)
embeddings <- tibble(
tokens = c("the", "cat", "ran"),
d1 = c(1, 0, 0),
d2 = c(0, 1, 0),
d3 = c(0, 0, 1)
)
sample_data <- tibble(
text = c(
"The.",
"The cat.",
"The cat ran."
),
text_label = c("fragment", "fragment", "sentence")
)
rec <- recipe(text_label ~ ., data = sample_data) %>%
step_tokenize(text) %>%
step_word_embeddings(text, embeddings = embeddings)
obj <- rec %>%
prep()
bake(obj, sample_data)
tidy(rec, number = 2)
tidy(obj, number = 2)
# }
Run the code above in your browser using DataLab