| step_lemma | R Documentation |
step_lemma() creates a specification of a recipe step that will extract
the lemmatization of a token variable.
step_lemma(
recipe,
...,
role = NA,
trained = FALSE,
columns = NULL,
skip = FALSE,
id = rand_id("lemma")
)
recipe |
A |
... |
One or more selector functions to choose which variables are
affected by the step. See |
role |
Not used by this step since no new variables are created. |
trained |
A logical to indicate if the quantities for preprocessing have been estimated. |
columns |
A character vector of the selected variable names. This is
|
skip |
A logical. Should the step be skipped when the recipe is baked
by |
id |
A character string that is unique to this step to identify it. |
This stem doesn't perform lemmatization by itself, but rather lets you
extract the lemma attribute of the token variable. To be
able to use step_lemma you need to use a tokenization method that includes
lemmatization. Currently using the "spacyr" engine in step_tokenize()
provides lemmatization and works well with step_lemma.
An updated version of recipe with the new step added
to the sequence of existing steps (if any).
When you tidy() this step, a tibble is returned with
columns terms and id:
character, the selectors or variables selected
character, id of this step
The underlying operation does not allow for case weights.
step_tokenize() to turn characters into tokens
Other Steps for Token Modification:
step_ngram(),
step_pos_filter(),
step_stem(),
step_stopwords(),
step_token_replace(),
step_tokenfilter(),
step_tokenmerge()
## Not run:
library(recipes)
short_data <- data.frame(text = c(
"This is a short tale,",
"With many cats and ladies."
))
rec_spec <- recipe(~text, data = short_data) |>
step_tokenize(text, engine = "spacyr") |>
step_lemma(text) |>
step_tf(text)
rec_prepped <- prep(rec_spec)
bake(rec_prepped, new_data = NULL)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.