knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" ) reticulate::use_virtualenv("./env", required = TRUE)
Integrates TextBlob with R.
First, install the package using remotes
.
# install.packages("remotes") remotes::install_github("news-r/textblob")
Then install the python dependencies, only do this one per virtual environment.
# replace with path of your choice my_env <- "./env" # run this (works on unix) args <- paste("-m venv", my_env) system2("python3", args) # create environment reticulate::use_virtualenv(my_env) # force reticulate to use env # install textblob in environment textblob::install_textblob(my_env)
Then download the necessary NLTK datasets, note that there is a lite version.
# download corpora textblob::download_corpora()
This will install textblob
and download the necessary NLTK corpora.
library(textblob) string <- paste( "R is a programmming langage and free software", "environment for statistical computing and", "graphics supported by the R Foundation for", "Statistical Computing." ) wiki <- text_blob(string) wiki$sentiment # get sentiment wiki$correct() # correct programmming langage wiki$translate(to = "es") # translate
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.