Git Product home page Git Product logo

gramr's Introduction

gramr

Travis-CI Build Status Coverage Status Last-changedate minimal R version Licence

The goal of gramr is to help R programmers who can't write good and and wanna learn to do other stuff good too by checking a RMarkdown document for grammatical errors.

This package wraps the command line tool, write-good to provide grammar checking functions for Rmd or md documents. It can be used as an RStudio Addin, or from the console or command line by supplying an Rmd or md filename.

Installation

You can install gramr from github with:

# install.packages("devtools")
devtools::install_github("ropenscilabs/gramr")

Examples

write_good_ip(): run the write-good linter on text in a currently active Rmd file in RStudio

write_good_file("my_file.Rmd"): run the write-good linter on text in an Rmd file (RStudio not required)

run_grammar_checker("example.rmd"): run the write-good linter interactively

Example Output:

> write_good_file("tests/testthat/test.Rmd")

#  index offset                              reason
#1    15     12 "been defined" may be passive voice
#2    49      8       "suddenly" can weaken meaning

Contributing

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Acknowledgements

Thanks to Brian Ford for the development of write-good!

gramr's People

Contributors

benmarwick avatar jasdumas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gramr's Issues

Options for grammer checker:

https://github.com/btford/write-good

I think this could work well for checking RMD text. I guess the user flow would be something like:

  1. In RStudio addin, the user selects which checks they want to use
  2. Break RMD text into sentences
  3. Pass each sentence through the writeGood() function
  4. Display the sentence in an editable textbox with the suggestions below,
  5. User makes changes to sentence, then clicks next at which pointed the changed text is stored in an array
  6. After all chunks are checked, replace corrected text in the document

Is that roughly what you were envisioning?

write-good output

A future development task and discussion could be to synthesize the output for readability or in a tidy format so that the changes can be implemented programmatically. The API currently displays the index position along with the reason for output. The CLI displays an output similar to how word processing spell checkers communicate suggestions for editing with the underline.

> jasminedumas~/Desktop/GitHub Clone Repos/gramr: write-good --text="It should have been defined there."
In text
=============
It should have been defined there.
               ^^^^^^^^^^^^
"been defined" may be passive voice on line 1 at column 15

For example in a tidy format:

position original_sentence reason
line 1 at column 15 It should have been defined there. "been defined" may be passive voice

Unable to analyze whole Rmd document

Hello,

I have spent the last few hours reading documentation on your package, I was intrigued to know if any development has occured on Issue #8; adding the functionality showing "line numbers" to gramr. When I run write_good_file("test.Rmd") on a larger document its nearly impossible to find the associated text in the Rmd.

I have tried to use the run_grammar_checker() function but I have noticed that this does not run the entire file. Possible due to the function performing grammar checks on code chunks. To reproduce the issue, add the lines of code shown below to test_multiple_lines.Rmd (which you can find in this repo here).

I am curious how other users use the package...do you run run_grammar_checker() on every paragraph within your Rmd file?

Any suggestions would be great. I would love to use this package while writing articles.

```{r setup, include=FALSE, echo=FALSE}
knitr::opts_chunk$set(fig.cap = TRUE,
                      fig.path = 'images/',
                      echo = FALSE,
                      warning = FALSE, 
                      message = FALSE,
                      include = TRUE,
                      dpi = 300,
                      crop = TRUE # This will remove the whitespace surrounding an image see here: https://bookdown.org/yihui/rmarkdown-cookbook/crop-plot.html
                      # The following chunks only work with PDF outputs
                      #fig.pos = 'H', # only works with PDFs
                      #fig.align = 'center', # only works with PDFs
                      #out.height="100%",  out.width="100%") # only works with PDFs
                      )
# Abstract

::: {custom-style="Email_Note"}
***Journal Instructions*** Original Investigations (Perioperative Medicine, Critical Care Medicine, Pain Medicine, and Education) require a structured abstract. It should be limited to 300 words. The structured abstract should contain four labeled paragraphs: Background, Methods, Results, and Conclusions. Abstracts may be the only part of an article which is read, and must stand alone from the body of the manuscript. In order to enhance comprehension, the use of nonstandard abbreviations or acronyms in the Abstract is not allowed.

A list of standard abbreviations accepted by the journal may be found at anesthesiology.pubs.asahq.org/DocumentLibrary/08302018_abbreviations.pdf

Review Articles and Special Articles require an unstructured, one- or two-paragraph summary of the key points of the article of 150 words or fewer.

Make sure the text of the Abstract in the manuscript file and in the system match exactly
:::

It should have been defined there. But it wasn't suddenly

When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

Output of the functions

Many thanks for providing this package. As non native speaker is sometimes difficult to know if I am writing well.

I have used the gramr::write_good_file to check a file. The output is below:

| index| offset|reason                                           |
|-----:|------:|:------------------------------------------------|
|   578|     13|"was developed" may be passive voice             |
|   757|      7|"several" is a weasel word                       |
|  1234|      4|"only" can weaken meaning                        |
|  1890|      4|"only" can weaken meaning                        |
|  1983|      9|"There are" is unnecessary verbiage              |
|  2157|      7|"optimum" is wordy or unneeded                   |
|  2712|      5|"it is" is wordy or unneeded                     |
|  3054|      4|"just" can weaken meaning                        |
|  3154|      5|"it is" is wordy or unneeded                     |
|  3427|      6|"fairly" is a weasel word and can weaken meaning |
|  3484|      9|"perfectly" can weaken meaning                   |
|  3716|      6|"fairly" is a weasel word and can weaken meaning |
|  3723|     10|"similar to" is wordy or unneeded                |
|  3802|      6|"fairly" is a weasel word and can weaken meaning |
|  4522|      3|"the" is repeated                                |
|  4541|     13|"approximately" can weaken meaning               |

I couldn't find in the help page what is this index or the offset. Could someone explain it? It is easy to find the words but It would be easier to know the line of the file where to find those words.

Error when executing the write_good_ip() func

Error in context_eval(join(src), private$context) : 
  TypeError: Object [object Array] has no method 'substr'

This is the Untitled doc that I should be working on and should be picking up the mistakes:


so dude This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.

When you click click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

Optionally exclude code chunks when handling Rmd files

When running write_good_file() on a vignette I get the message "aggregate" is wordy or unneeded. In this case, it refers to the aggregate() function. It would be nice to exclude R code chunk from the check to avoid false positives.

write_good_file not as a Addin?

I'm wondering if write_good_file() may work better just as a function? Things are getting quirky when loading the addin and there is no filename specified initially

> gramr:::write_good_file()
1: "test/testthat/test.Rmd"
2: 
write-good found no problems. Your writing is good!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.