项目作者: ropensci

项目描述 :
Tools for Spell Checking in R
高级语言: R
项目地址: git://github.com/ropensci/spelling.git
创建时间: 2017-08-25T11:59:13Z
项目社区:https://github.com/ropensci/spelling

开源协议:Other

下载


spelling

Project Status: Active – The project has reached a stable, usable state and is being actively developed.
CRAN_Status_Badge
CRAN RStudio mirror downloads

Tools for Spell Checking in R

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.

Spell Check Single Files

The function spell_check_files automatically parses known text formats and only spell checks text blocks, not code chunks.

  1. spell_check_files('README.md', lang = 'en_US')
  2. # WORD FOUND IN
  3. # AppVeyor README.md:5
  4. # CMD README.md:12
  5. # RStudio README.md:8

For more information about the underlying spelling engine and how to add
support for other languages, see the hunspell package.

screenshot

Spell Check a Package

Spell check documentation, description, readme, and vignettes of a package:

  1. spell_check_package("~/workspace/V8")
  2. # DESCRIPTION does not contain 'Language' field. Defaulting to 'en-US'.
  3. # WORD FOUND IN
  4. # ECMA V8.Rd:16, description:2,4
  5. # emscripten description:5
  6. # htmlwidgets JS.Rd:16
  7. # JSON V8.Rd:33,38,39,57,58,59,121
  8. # jsonlite V8.Rd:42
  9. # Ooms V8.Rd:41,121
  10. # th description:3
  11. # Xie JS.Rd:26
  12. # Yihui JS.Rd:26

Review these words and then update the wordlist to allow them:

  1. update_wordlist("~/workspace/V8")
  2. # The following words will be added to the wordlist:
  3. # - ECMA
  4. # - emscripten
  5. # - htmlwidgets
  6. # - JSON
  7. # - jsonlite
  8. # - Ooms
  9. # - th
  10. # - Xie
  11. # - Yihui
  12. # Are you sure you want to update the wordlist?
  13. # 1: Yes
  14. # 2: No

Then these will no longer be marked as errors:

  1. > spell_check_package("~/workspace/V8")
  2. No spelling errors found.

Automate Package Spell Checking

Use spell_check_setup() to add 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.

  1. spell_check_setup("~/workspace/V8")
  2. # Adding 'Language: en-US' to DESCRIPTION
  3. # No changes required to /Users/jeroen/workspace/V8/inst/WORDLIST
  4. # Updated /Users/jeroen/workspace/V8/tests/spelling.R

Note that the NOT_CRAN variable is automatically set to 1 on Travis and in devtools or RStudio, otherwise you need to set it yourself:

  1. export NOT_CRAN=1
  2. R CMD check V8_1.5.9000.tar.gz
  3. # * using log directory ‘/Users/jeroen/workspace/V8.Rcheck’
  4. # * using R version 3.5.1 (2018-07-02)
  5. # * using platform: x86_64-apple-darwin15.6.0 (64-bit)
  6. # ...
  7. # ...
  8. # * checking tests ...
  9. # Running ‘spelling.R’
  10. # Comparing ‘spelling.Rout’ to ‘spelling.Rout.save’ ... OK
  11. # Running ‘testthat.R’
  12. # OK