Skip to contents

Tokenises text (splitting on whitespace, lower-casing, and stripping punctuation), removes stop words, and counts term frequency. Ships a small built-in English stop-word list so this works with zero optional packages. Pass stop_words = character(0) to disable filtering, or a custom vector to override it.

Usage

sframe_term_frequency(text, stop_words = NULL, top_n = 30L)

Arguments

text

Character vector of responses (raw or already cleaned by sframe_clean_text()).

stop_words

Character vector of words to exclude, or NULL to use the built-in English list, or character(0) for no filtering.

top_n

Integer. Maximum number of terms to return, most frequent first. Default 30.

Value

A data.frame with columns term, n, and pct.

Examples

demo <- sframe_demo("tourism_services")
cleaned <- sframe_clean_text(demo$responses, "comments")
head(sframe_term_frequency(cleaned, top_n = 10))