knitr::opts_chunk$set( collapse = TRUE, comment = "#>", message = FALSE, fig.path = "man/figures/", out.width = "100%" )
This package makes it possible to use LanguageTool from R to correct some text. It currently proposes a Shiny app to edit rmarkdown documents. In the future, another app will be developed to edit packages documentation.
You can install this package from GitHub, maybe it will be on CRAN one day.
To use all the new features before they are available in the CRAN version, you can download the development version.
devtools::install_github("JeremyGelb/langCorrector")
You will need to download the jar file from LanguageTool.
library(langCorrector) install_LanguageTools()
And check if it worked.
is_LanguageTools_installed()
Also, you need to ensure that java (64 bits) is installed on your computer and can be run from the command line.
check_java()
If java is not installed, or if you have the 32-bits version please download it and install it.
Also, if you are using Windows, you must ensure that java location was added to your Path.
Finally, you can use LanguageTool for the first time and install locally a list of all the available languages.
install_lang_list() # need to be done only once get_lang_list()
You want to find grammatical errors in a rmd document? The easiest option is to use the Shiny app provided with the package!
library(langCorrector) my_file <- 'path/to/my/rmdfile.rmd' lang <- "en" rmd_corrector(my_file, language = lang, port = 8807)
You could also decide to use it directly from R by running the LanguageTool server manually.
my_server <- starting_server(port = 8807) my_text <- "Some text with a obvious mistake." corrections <- send_request(port = 8807, text = my_text, language = "en")
Do not forget to stop the server when you are done. You don't want to have orphan processes running in the background!
killing_server(my_server)
If you encounter a bug when using langCorrector, please open an issue here. To ensure that the problem is quickly identified, the issue should follow the following guidelines:
I would like to improve the package by using rJava instead of a server based approach, I you have some clue about how it works, feel free to contact me!
langCorrector
is licensed under GPL2 License.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.