Is there a way to evaluate a string and see if it evaluates to a word in English? Here is what I am looking for
is.word("hello world")
[1] FALSE
is.word(c("hello", "world")
[1] TRUE TRUE
The above does not work as there is no is.word
logical function.
As the comments have pointed out, you need an English dictionary to match against. The GradyAugmented
object in the qdapDictionary
package is one such dictionary:
A dataset containing a vector of Grady Ward's English words augmented with ‘DICTIONARY’, Mark Kantrowitz's names list, other proper nouns, and contractions.
library(qdapDictionaries)
is.word <- function(x) x %in% GradyAugmented
is.word(c("hello world"))
## [1] FALSE
is.word(c("hello", "world"))
## [1] TRUE TRUE
is.word(c("asfasdf"))
## [1] FALSE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With