Skip to content

textrecipes (development version)

textrecipes 1.2.0

CRAN release: 2026-11-03

New Steps

  • step_sentence_embeddings() converts a character column into dense embeddings from a pretrained model. The step stores a reference to the model rather than the model itself, checks that the embedding dimension is unchanged when baking, and caches embeddings within the R session. The embedding model is chosen with an engine, see the new “Sentence embeddings” vignette. (#303)
    • embedding_custom() supplies your own embedding function.
    • embedding_ollama() gets embeddings from a running Ollama server using httr2.
    • embedding_huggingface() runs a sentence-transformers model from the Hugging Face Hub in Python through reticulate. The model is pinned with a required revision, and the loaded model is kept for the R session but never stored in the recipe.
    • embedding_model2vec() embeds text with a downloaded Model2Vec model entirely in R, without Python or a server. The model is read once per R session. (#301)
  • step_token_replace() replaces tokens in a token variable according to pattern and replacement vectors, matching either exactly or with regular expressions. (#134)

Improvements

  • step_tokenize(), step_tokenize_bpe(), step_tokenize_sentencepiece(), and step_stem() now validate their options argument with recipes::check_options() and give informative errors for unnamed, non-list, or disallowed elements. (#291)

  • step_tokenize() documentation now states that training_options also applies to engine = "udpipe", where it must contain the loaded model, and includes an example. (#237)

  • step_tokenize_sentencepiece() gains a model argument, which takes the path to a pretrained sentencepiece model to use instead of training a new one. (#278)

  • step_pos_filter() gains a remove_tags argument, which removes tokens with the given part of speech tags instead of keeping them. It can’t be used together with keep_tags. (#218)

  • New read_embeddings_model2vec() and read_embeddings_bpemb() read downloaded Model2Vec and BPEmb files into the tibble that step_word_embeddings() takes as embeddings. New download_embeddings_model2vec() downloads a Model2Vec model. (#303)

  • The counting functions in count_functions, used by step_textfeature(), are now faster. The word-list counts (first_person(), prepositions(), etc.) are about 2x faster, the n_uq_*() counts are 2 to 5x faster, and n_uq_charS() uses less memory on large inputs. (#267)

  • Argument documentation has been revised across all steps to follow the tidyverse style guide: defaults are now stated, fixed sets of values are listed, code is formatted consistently, and the descriptions of res, smooth_idf, norm, and vocabulary are now accurate. (#263)

  • Documentation now links to the external functions that do the underlying work in several steps, such as janitor::make_clean_names() in step_clean_levels() and step_clean_names(). (#198)

  • New vignettes:

    • “Tokenizers” gives an overview of the tokenization options and how they change the resulting tokens. (#158)
    • “Using textrecipes as a sparse matrix engine” documents which steps produce sparse data and how to use them. (#302)
    • “Sentence embeddings” shows how to use step_sentence_embeddings() with its engines. (#303)
    • “Static embeddings with Model2Vec and BPEmb” shows how to use the new read_embeddings_*() helpers, and includes a section on training your own embeddings with wordsalad’s glove(), word2vec(), and fasttext() for use with step_word_embeddings(). (#102, #103, #104, #303)

Bug Fixes

  • All steps now work with 0 and 1 row data in bake(). This fixes errors in step_texthash(), step_dummy_hash(), step_lda(), and step_pos_filter() with 0 rows, and zero-length tokenlists no longer lose their lemma and pos attributes, which broke step_lemma(). (#290)

  • Custom tokenizer functions passed to custom_token are now called positionally, so functions whose first argument isn’t named x no longer error with “unused argument” at bake time. (#248)

  • first_person(), first_personp(), second_person(), second_personp(), third_person(), to_be(), and prepositions() (used by step_textfeature()) now tokenize the document into words and check whether it contains the word. Previously they tested whether the word matched the entire untokenized document, which almost always returned 0. (#316)

  • The counting functions used by step_textfeature() are now more consistent (#329):

    • n_uq_urls() counts distinct full urls instead of being capped at 2 distinct matches of the literal substring “http” or “https”.
    • n_charS() and n_uq_charS() now exclude urls, hashtags, and mentions from the character count, as documented.
    • n_extraspaces() no longer counts a single tab or newline as extra spaces. It only counts runs of 2 or more consecutive whitespace characters.
    • All counting functions return NA when given NA input.
  • show_tokens() now validates the upper bound of the n argument (nrow(rec$template)) and gives a clear error, instead of a confusing, unrelated one. (#322)

  • step_clean_levels() now restores the trained column names for legacy trained objects, so bake() no longer silently skips cleaning. (#321)

  • step_clean_levels() now gives character columns a cleaning dictionary at prep() time, so bake() uses a fixed lookup instead of applying janitor::make_clean_names() to the batch of values being baked. (#320)

  • step_dummy_hash() now restores the original columns when keep_original_cols = TRUE and collapse = TRUE, and no longer leaks the intermediate collapsed column into the output. (#304)

  • step_dummy_hash() and step_texthash() no longer crash (segfault) when num_terms = 0. They now error cleanly during prep(). (#314)

  • step_lda() now produces deterministic topic features at bake time. bake() reuses the vocabulary learned during prep() and projects each document independently, so topic weights sum to about 1 and no longer depend on what else is in the same bake() call. (#315)

  • step_ngram() now errors clearly when num_tokens or min_num_tokens is less than 1, and when min_num_tokens is greater than num_tokens, instead of surfacing an unrelated low-level error. (#324)

  • step_ngram() no longer mislabels non-UTF-8 (e.g. latin1) input as UTF-8, which could cause nchar(), toupper(), and other string operations on the output to fail with encoding errors. (#323)

  • step_sequence_onehot() now errors clearly when sequence_length is less than 1. (#324)

  • step_stem() no longer drops the lemma and pos attributes carried by a tokenlist, so it can be used before step_lemma() or step_pos_filter(). (#327)

  • step_texthash() no longer errors with “values value must not be equal to the default 0” when baking with sparse = "yes" and signed = TRUE (the default) and signed hash collisions cancel out to zero. (#289)

  • step_tfidf() with sublinear_tf = TRUE no longer produces negative values, because the sublinear transform is now applied before normalization instead of after. (#317)

  • step_tokenize(), step_tokenize_bpe(), step_tokenize_sentencepiece(), and step_tokenize_wordpiece() now error informatively if a tokenizer returns a list whose length doesn’t match the number of rows in the input, instead of silently recycling and duplicating rows. (#318)

  • step_tokenize() with engine = "spacyr" or engine = "tokenizers.bpe", step_tokenize_bpe(), and step_tokenize_sentencepiece() no longer error with “unused argument” in bake() when options is non-empty. (#319)

  • step_tf() and step_tfidf() documentation now states that the denominator for weight_scheme = "term frequency" and norm = "l1" is the number of in-vocabulary tokens, not the total number of words. (#326)

  • step_word_embeddings() documentation now describes the actual default prefix and column-naming behavior. (#331)

Developer

  • bake() methods for steps that transform columns in place now use recipes_map_cols(), which avoids copying the data frame once per column and is much faster with many columns. This requires recipes >= 1.4.0. (#312)

textrecipes 1.1.0

CRAN release: 2025-03-18

Improvements

textrecipes 1.0.7

CRAN release: 2025-01-23

Improvements

  • Documentation for tidy methods for all steps has been improved to describe the return value more accurately. (#262)

  • Calling ?tidy.step_*() now sends you to the documentation for step_*() where the outcome is documented. (#261)

  • step_textfeatures() has been made faster and more robust. (#265)

Bug Fixes

textrecipes 1.0.6

CRAN release: 2023-11-15

  • textfeatures has been removed from Suggests. (#255)

  • step_textfeatures() no longer returns a politeness feature. (#254)

textrecipes 1.0.5

CRAN release: 2023-10-20

textrecipes 1.0.4

CRAN release: 2023-08-17

Improvements

  • step_clean_names() now throw an informative error if needed non-standard role columns are missing during bake(). (#235)

  • The keep_original_cols argument has been added to step_tokenmerge. This change should mean that every step that produces new columns has the keep_original_cols argument. (#242)

  • Many internal changes to improve consistency and slight speed increases.

Bug Fixes

textrecipes 1.0.3

CRAN release: 2023-04-14

Improvements

  • Steps with tunable arguments now have those arguments listed in the documentation.

  • All steps that add new columns will now informatively error if name collision occurs.

Bug Fixes

  • Fixed bug where step_tf() wasn’t tunable for weight argument.

textrecipes 1.0.2

CRAN release: 2022-12-21

textrecipes 1.0.1

CRAN release: 2022-10-06

  • Examples no longer include if (require(...)) code.

textrecipes 1.0.0

CRAN release: 2022-07-02

  • Indicate which steps support case weights (none), to align documentation with other packages.

textrecipes 0.5.2

CRAN release: 2022-05-04

  • Remove use of okc_text in vignette

  • Fix bug in printing of tokenlists

textrecipes 0.5.1

CRAN release: 2022-03-29

textrecipes 0.5.0

CRAN release: 2022-03-20

New steps

Improvements and Other Changes

Breaking Changes

  • Steps with prefix argument now creates names according to the pattern prefix_variablename_name/number. (#124)

textrecipes 0.4.1

CRAN release: 2021-07-11

Bug fixes

textrecipes 0.4.0

CRAN release: 2020-11-12

Breaking Changes

  • step_lda() now takes a tokenlist instead of a character variable. See readme for more detail.

New Features

textrecipes 0.3.0

CRAN release: 2020-07-08

  • stopwords package have been moved from Imports to Suggests.
  • step_ngram() gained an argument min_num_tokens to be able to return multiple n-grams together. (#90)
  • Adds step_text_normalization() to perform unicode normalization on character vectors. (#86)

textrecipes 0.2.3

CRAN release: 2020-05-22

textrecipes 0.2.2

CRAN release: 2020-05-10

  • step_word_embeddings() got a argument aggregation_default to specify value in cases where no words matches embedding.

textrecipes 0.2.1

CRAN release: 2020-05-04

textrecipes 0.2.0

CRAN release: 2020-04-14

textrecipes 0.1.0

CRAN release: 2020-03-05

textrecipes 0.0.2

CRAN release: 2019-09-07

  • Custom stemming function can now be used in step_stem using the custom_stemmer argument.
  • step_textfeatures() have been added, allows for multiple numerical features to be pulled from text.
  • step_sequence_onehot() have been added, allows for one hot encoding of sequences of fixed width.
  • step_word2vec() have been added, calculates word2vec dimensions.
  • step_tokenmerge() have been added, combines multiple list columns into one list-columns.
  • step_texthash() now correctly accepts signed argument.
  • Documentation have been improved to showcase the importance of filtering tokens before applying step_tf() and step_tfidf().

textrecipes 0.0.1

CRAN release: 2018-12-17

First CRAN version