# The tm package in R provides the stemDocument() function to stem document word.
# This function either takes in a character vector and returns a character vector, 
# or takes in a PlainTextDocument and returns a PlainTextDocument.
# ex: stemDocument(running,runs,ran) returns (run,run,ran) as the ouput

# a bug in StemDocument:
# https://stackoverflow.com/questions/54197636/how-is-the-correct-use-of-stemdocument
# A workaround could be using the package quanteda:
#install.packages("quanteda",repos = "http://cran.us.r-project.org")

library(tm)

word = "running" 
stemDocument(word, language = "english")

word = "image" 
stemDocument(word, language = "english")

word = "poder" # Spanish for "can" or "to be able to"
stemDocument(word, language = "spanish")

word = "potere" # Italian for "can" or "to be able to"
stemDocument(word, language = "italian")

