Title: | Tools for Spell Checking in R |
---|---|
Description: | Spell checking common document formats including latex, markdown, manual pages, and description files. Includes utilities to automate checking of documentation and vignettes as a unit test during 'R CMD check'. Both British and American English are supported out of the box and other languages can be added. In addition, packages may define a 'wordlist' to allow custom terminology without having to abuse punctuation. |
Authors: | Jeroen Ooms [cre, aut] , Jim Hester [aut] |
Maintainer: | Jeroen Ooms <[email protected]> |
License: | MIT + file LICENSE |
Version: | 2.3.1 |
Built: | 2024-11-02 05:42:56 UTC |
Source: | https://github.com/ropensci/spelling |
Perform a spell check on document files or plain text.
spell_check_files(path, ignore = character(), lang = "en_US") spell_check_text(text, ignore = character(), lang = "en_US")
spell_check_files(path, ignore = character(), lang = "en_US") spell_check_text(text, ignore = character(), lang = "en_US")
path |
path to file or to spell check |
ignore |
character vector with words which will be added to the hunspell::dictionary |
lang |
set |
text |
character vector with plain text |
This function parses a file based on the file extension, and checks only text fields while ignoring code chunks and meta data. It works particularly well for markdown, but also latex, html, xml, pdf, and plain text are supported.
For more information about the underlying spelling engine, see the hunspell package.
Other spelling:
spell_check_package()
,
wordlist
# Example files files <- list.files(system.file("examples", package = "knitr"), pattern = "\\.(Rnw|Rmd|html)$", full.names = TRUE) spell_check_files(files)
# Example files files <- list.files(system.file("examples", package = "knitr"), pattern = "\\.(Rnw|Rmd|html)$", full.names = TRUE) spell_check_files(files)
Automatically spell-check package description, documentation, and vignettes.
spell_check_package(pkg = ".", vignettes = TRUE, use_wordlist = TRUE) spell_check_setup(pkg = ".", vignettes = TRUE, lang = "en-US", error = FALSE)
spell_check_package(pkg = ".", vignettes = TRUE, use_wordlist = TRUE) spell_check_setup(pkg = ".", vignettes = TRUE, lang = "en-US", error = FALSE)
pkg |
path to package root directory containing the |
vignettes |
check all |
use_wordlist |
ignore words in the package WORDLIST file |
lang |
set |
error |
should |
Parses and checks R manual pages, rmd/rnw vignettes, and text fields in the
package DESCRIPTION
file.
The preferred spelling language (typically en-GB
or en-US
) should be specified
in the Language
field from your package DESCRIPTION
. To allow custom words,
use the package WORDLIST file which will be added to the dictionary
when spell checking. See update_wordlist to automatically populate and update this
file.
The spell_check_setup function adds a unit test to your package which automatically
runs a spell check on documentation and vignettes during R CMD check
if the environment
variable NOT_CRAN
is set to TRUE
. By default this unit test never fails; it merely
prints potential spelling errors to the console. If not already done,
the spell_check_setup function will add spelling
as a Suggests
dependency,
and a Language
field to DESCRIPTION
.
Hunspell includes dictionaries for en_US
and en_GB
by default. Other languages
require installation of a custom dictionary, see hunspell for details.
Other spelling:
spell_check_files()
,
wordlist
The package wordlist file is used to allow custom words which will be added to the
dictionary when spell checking. It is stored in inst/WORDLIST
in the source package
and must contain one word per line in UTF-8 encoded text.
update_wordlist(pkg = ".", vignettes = TRUE, confirm = TRUE) get_wordlist(pkg = ".")
update_wordlist(pkg = ".", vignettes = TRUE, confirm = TRUE) get_wordlist(pkg = ".")
pkg |
path to package root directory containing the |
vignettes |
check all |
confirm |
show changes and ask confirmation before adding new words to the list |
The update_wordlist function runs a full spell check on a package, shows the results,
and then prompts to add the found words to the package wordlist. Obviously you should
check closely that these legitimate words and not actual spelling errors. It also
removes words from the wordlist that no longer appear as spelling errors, either because
they have been removed from the documentation or added to the lang
dictionary.
Other spelling:
spell_check_files()
,
spell_check_package()