Git Product home page Git Product logo

wellspell.addin's Introduction

Project Status: Active – The project has reached a stable, usable state and is being actively developed. Travis-CI Build Status Coverage Status

wellspell.addin

wellspell is an RStudio Addin to quickly highlight spelling or
grammar errors in text documents. It employs the hunspell spell
checking engine via the hunspell package and the LanguageTool
grammar checking engine via the LanguageToolR package to do so.
Checking works for many languages.

Installation

Install the wellspell.addin R package from Github:
devtools::install_github("nevrome/wellspell.addin"). To enable
its features you need additional packages:

• Spellcheck

  • Install the hunspell R package that contains a standalone
    version of hunspell: install.packages("hunspell")

• Grammar check

  • Install the LanguageToolR R package
    devtools::install_github("nevrome/LanguageToolR"). It
    does not contain LanguageTool

  • Install LanguageTool manually or with the function
    LanguageToolR::lato_quick_setup()

  • Restart RStudio

Quickstart guide

To use wellspell.addin, you can select an arbitrary amount of text
in a text document in RStudio (e.g. a markdown, latex or html
document) and run spellcheck() or gramcheck(). As the
functions are registered as RStudio Addins, it is possible to run
them from the Addins dialogue or even with a keyboard shortcut
(e.g. Ctrl+Alt+7 and Ctrl+Alt+8).

At the first run in a new environment, spellcheck() and
gramcheck() will call set_config(), which is another Addin
with a minimalistic user interface. It allows you to set
environment variables to control the behaviour of the checking
tools. If the environment variables are set, spellcheck() and
gramcheck() select and thereby highlight all words/expressions
identified as wrong.

The additional functions get_config(), is_config() and
rm_config are for dealing with the environment variables and
usually don`t have to be called directly.

How to install hunspell dictionaries for other languages?

A default RStudio installation includes English dictionaries for
the US, UK, Canada, and Australia. In addition, dictionaries for
many other languages can be installed. To add these dictionaries,
go to the Spelling pane of the Options dialog, and select
Install More Languages… from the language dictionary select
box. This will download and install all of the available
languages. Further instructions can be found here. If this does
not work or the relevant languages are not in the default
selection you can install languages by copying the dictionary
files (.dic + .aff) to one of these locations:
hunspell::dicpath().

wellspell.addin's People

Contributors

gegznav avatar nevrome avatar yesdavid avatar

Stargazers

 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

wellspell.addin's Issues

All three addins fail to work on Windows

image

The grammar and spelling checking addins fail with error:

image

And the configuration addin also fails.
The error is simmilar to one reported in nevrome/LanguageToolR#2:

wellspell.addin:::set_config()
#> Error: Unable to access jarfile ~/LanguageTool-4.4/languagetool-commandline.jar
#>Error in languagetool(list_languages = TRUE) : 
#>  The provided executable is not available or does not work correctly. You can install #>LanguageTool with the quick_setup() function.

Session info is the same as in nevrome/LanguageToolR#2.

Can these errors be fixed?

Remove highlighting if no error is found.

Now the behavior of the add-in is a bit inconsistent: if errors are found, only the erroneous words are kept highlighted. If I select only one word and it has no errors it still is kept highlighted. If the "Markers" tab is closed (as is the case if we work in Rmd files), it's difficult to distinguish between words with and without spelling mistakes.

Related to #5.

gramcheck() Error in rjson::fromJSON(x) :

Hi all,

This is a very useful package specially for nonative english spekers! Many thanks to the contributors!

I just installed the packages and dependencies as suggested.

The wellspell.addin:::gramcheck() functions works as expected. However, when I run the wellspell.addin:::gramcheck(), I got the language selector pop-up window but then it prints the following error:

Error in rjson::fromJSON(x) :
CHAR() can only be applied to a 'CHARSXP', not a 'NULL'

Any ideas why I am not able to run it?

sessionInfo()
R version 4.2.1 (2022-06-23 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)

Matrix products: default

locale:
[1] LC_COLLATE=English_United Kingdom.utf8
[2] LC_CTYPE=English_United Kingdom.utf8
[3] LC_MONETARY=English_United Kingdom.utf8
[4] LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.utf8

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] shiny_1.6.0

More user-friendly names of dictionaries

RStudio uses user-friendly names of languages/dictionaries:

image

Is it possible to use more user-firendly dictionary names for both spellcheking and grammar checking in this addin?

Error : Marker message is unspecified or invalid

I ran the spellchecked with en_US distionary on the thext:

context <- rstudioapi::getSourceEditorContext()

And got the following error message:

Error : Marker message is unspecified or invalid: rstudioapi<U+2007><U+2007><U+2007><U+2007><U+2007><U+2007><U+2007><U+2007><U+2007><U+2007> | studious

It looks like an encoding issue. Is it possible to get a more informative error message?

Warning: Unknown or uninitialised column with wellspell.addin:::gramcheck()

Where are these warning messages coming from an how can they be avoided?

> wellspell.addin:::gramcheck()

Listening on http://127.0.0.1:7793

  |==================================================================| 100%
Warning messages:
1: Unknown or uninitialised column: 'context_text'. 
2: Unknown or uninitialised column: 'rule_category_name'. 
3: Unknown or uninitialised column: 'message'. 
4: Unknown or uninitialised column: 'context_text'. 
5: Unknown or uninitialised column: 'rule_category_name'. 
6: Unknown or uninitialised column: 'message'. 

Why core dependencies are in "Suggests" and not in "Imports"?

In DESCRIPTION file, packages hunspell and LanguageToolR arein section "Suggests":

Suggests:
  hunspell,
  LanguageToolR (>= 0.1.2)

These packages give core functionality for the add-in and dependencies in "Suggests" are not always downloaded. Shouldn't these packages be moved to "Imports" (or even "Depends")?

Non-informative message if packages are missing

Non-informative message/output if both 'hunspell' and 'LanguageToolR' are missing.

> wellspell.addin:::gramcheck()

Listening on http://127.0.0.1:7446
Warning: Error in if: argument is of length zero
  81: observeEventHandler [D:/r/wellspell.addin/R/wellspell_config.R#245]
  10: shiny::runApp
   9: shiny::runGadget
   8: set_config [D:/r/wellspell.addin/R/wellspell_config.R#265]
   7: check [D:/r/wellspell.addin/R/wellspell.R#100]
   1: wellspell.addin:::gramcheck [D:/r/wellspell.addin/R/wellspell.R#7]

Optimize loading time for "welspell_config"

When I try to open "welspell_config" window, on my PC it takes several seconds to open. Sometimes I start doubting if I even pressed the hot-key combination to open the tool.

I did some quick profiling. One of the bottlenecks on LanguageToolR side is function "lato_list_languages"
image

Next, lato_test_setup() is called several times.
image

Is it possible to optimize these processes?

Some ideas would be:

  • to open window and load contents asynchronously: first, the window could be created and, next, the contents are updated. Some spinner of progress bar could be added to indicate, that the settings are still loading.
  • to open the settings of spelling and grammar tools asynchronously (only when required tab is activated). It would be time saver especially if we need only one tool but not both.

Progress bar stops at less than 100% with no error message

The progress bar of spellchecker does not always come to 100%. Here is a print screen:

image

E.g., when I run the spellchecker tool (en_US dictionary) on the text

  if (as.character(unlist(context$selection)["text"]) == "") {
    stop("No text selected.", call. = FALSE)
  }

I get only 33%:

image

Is this behavior expected or is there a hidden issue?

CI and unit tests

The increase of activity in this repo justifies automatic checks. This should be combined with unit tests, but these might be difficult to design for this package.

Wrong config tab opens for grammar checking

Even if the grammar checking tool is used, in configuration gadget the tab with the spellchecking options is opened. It is a bit confusing. It would be better if a correct tab would open. It is even more confusing when "hunspell" is not installed and a warning message appears instead of option to choose the language for grammar checking.

Enable possibility to check spelling in new (unsaved) documents

Now wellspell.addin requires the documents to be saved on a hard drive before using the tool:

"Unknown source file path. Is the file where you apply 'wellspell' saved?"

And this creates inconvenience in some situations.

Would it be possible to use the wellspell.addin in new (unsaved) documents?
Should any part of functionality be lost in order to have the feature?

Ignore line wrap in gramcheck()

When automatic line wrapping is activated, as described here, gramcheck function will mark two mistakes in every line: "This sentence does not star with an uppercase letter" and "Please add a punctuation mark at the end of paragraph".
Is there a way to force it to ignore single line breaks in order to avoid those messages?

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.