Description Usage Arguments Value Note See Also Examples
Lemmatize a vector of strings.
1 | lemmatize_strings(x, dictionary = lexicon::hash_lemmas, ...)
|
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 |
Returns a vector of lemmatized strings.
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.