lemmatize_strings {textstem} | R Documentation |
Lemmatize a Vector of Strings
Description
Lemmatize a vector of strings.
Usage
lemmatize_strings(x, dictionary = lexicon::hash_lemmas, ...)
Arguments
x |
A vector of strings. |
dictionary |
A dictionary of base terms and lemmas to use for
replacement. The first column should be the full word form in lower case
while the second column is the corresponding replacement lemma. The default
makes the dictionary from the text using
|
... |
Other arguments passed to |
Value
Returns a vector of lemmatized strings.
Note
The lemmatizer splits the string apart into tokens for speed optimization. After the lemmatizing occurs the strings are pasted back together. The strings are not guaranteed to retain exact spacing of the original.
See Also
Examples
x <- c(
'the dirtier dog has eaten the pies',
'that shameful pooch is tricky and sneaky',
"He opened and then reopened the food bag",
'There are skies of blue and red roses too!',
NA,
"The doggies, well they aren't joyfully running.",
"The daddies are coming over...",
"This is 34.546 above"
)
## Default lexicon::hash_lemmas dictionary
lemmatize_strings(x)
## Hunspell dictionary
lemma_dictionary <- make_lemma_dictionary(x, engine = 'hunspell')
lemmatize_strings(x, dictionary = lemma_dictionary)
## Bigger data set
library(dplyr)
presidential_debates_2012$dialogue %>%
lemmatize_strings() %>%
head()
## Not run:
## Treetagger dictionary
lemma_dictionary2 <- make_lemma_dictionary(x, engine = 'treetagger')
lemmatize_strings(x, lemma_dictionary2)
lemma_dictionary3 <- presidential_debates_2012$dialogue %>%
make_lemma_dictionary(engine = 'treetagger')
presidential_debates_2012$dialogue %>%
lemmatize_strings(lemma_dictionary3) %>%
head()
## End(Not run)