-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.Rmd
80 lines (58 loc) · 1.81 KB
/
README.Rmd
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
---
output:
github_document:
html_preview: false
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
reticulate::use_virtualenv("./env", required = TRUE)
```
<!-- badges: start -->
[](https://travis-ci.org/news-r/textblob)
[](https://www.tidyverse.org/lifecycle/#experimental)
<!-- badges: end -->
# textblob
Integrates [TextBlob](https://textblob.readthedocs.io) with R.
## Installation
First, install the package using `remotes`.
``` r
# install.packages("remotes")
remotes::install_github("news-r/textblob")
```
Then install the python dependencies, only do this one per virtual environment.
```r
# 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.
```r
# download corpora
textblob::download_corpora()
```
This will install `textblob` and download the necessary NLTK corpora.
## Example
```{r example}
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
```