stringr is an R package for consistent string manipulation and pattern matching. It helps prepare text by splitting sentences into characters, words, or other tokens before converting them into numeric representations. section 14.2
Split a sentence into words
Use boundary("word") with str_split() to identify words. Preserve punctuation with skip_word_none = FALSE, then remove whitespace-only elements with str_subset("\\S"). The result can include both words and punctuation, ready for vocabulary matching. section 14.2
Common stringr splitting choices include:
- Use str_split(x, "") or boundary("character") for Unicode-aware character splitting. section 14.2
- Use boundary("word") for word splitting based on ICU word-boundary rules. section 14.2
