DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • AI-Powered CI Test Failure Triage
  • When a Coding Agent Fixes the Test Instead of the Bug
  • Testing Java and Spring Applications With Kotlin: Low-Risk to Adoption
  • Your Visual Regression Suite Is Mostly Testing Anti-Aliasing

Trending

  • AI Agents Need an Identity Plane: Rethinking Enterprise Authorization for Autonomous Software
  • Why AI Agents Need a Shared Enterprise Ontology
  • Share Delta Lake Tables Between Databricks and Snowflake
  • How You Clear Your HTML5 Canvas Matters

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Testing, Tools, and Frameworks
  4. Vale for Spelling, Grammar, Style and Readability Linting

Vale for Spelling, Grammar, Style and Readability Linting

If you've wanted a spell checker or autocorrect that simply does more, check out how this tool is bein used to check for tense and syle as well.

By 
Chris Ward
DZone Core CORE ·
Updated Aug. 14, 18 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
11.6K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

I spent last week hacking with contributors at the Test the Docs project in Szeged, Hungary. The project aims to create tools that are both usable by developers who aren't good writers, and writers who aren't good developers. The tools are for testing structural and content issues with writing, often called linting, a topic I have written about before. We're working on an easy to use wrapper tool (working title "redactor") that bundles a series of tests together, but for this post, I focus on one of those tests.

A common ask from writers is a tool that checks beyond standard grammar and spelling checks to also include personal or company style guides. We wanted to create a tool that handles this use case and a form of open source Grammarly or Hemmingway App.

A handful of tools are available that help you "codify" a style guide which all require a degree of configuration. We considered two options that allow you to combine human language linters into a cohesive tool, textlint and vale. Despite textlint's more active community, we opted to use vale.

Textlint takes a more JavaScript-esque approach, with a wide variety of textlint compatible plugins available to match a wide variety of tests. This means that lots of prebuilt options are available to install and use with a varying degree of configuration, but in true JavaScript fashion, this means a lot of dependencies and code for discrete and straightforward tasks.

Vale takes a different approach, providing one linter, and a selection of nine checks that you combine to recreate most common language linting tasks. For example, if you want to search for "weasel words," create an existence check for a selection of words, and Vale handles the rest. You can find prebuilt vale versions of popular style guides, but you need to research how to create specific tests not covered.

If you don't want to create your own style, or want a starting point to build from, we created a pre-packed test you can run. This test bundles a set of checks we feel are the most important that you can see in the <.vale.ini> configuration file (Read the vale docs for more configuration explanation), and we have a wide variety of reference checks available built from popular style guides.

Installation and Usage

For our packaged version, use Docker to pull and run the container, or you can dig into our setup and run vale how you like.

docker run -v <LOCAL-DOCS-FOLDER>:/srv/docs testthedocs/ttd-mdlint

Checks We Hoped to Replicate

Grammarly doesn't publish a list of the checks it runs, we used a test article to figure out some of the common ones, how to replicate them, and added a handful of others we felt were important. I'll explain a couple below (from our complete list) to help you understand how to create your own.

Removing TODOs and Other Annotations

This rule is part of the default vale.Annotations rule shipped with Vale.

extends: existence
message: "'%s' left in text."
ignorecase: false
level: error
tokens:
  - FIXME
  - TODO
  - NOTE

It uses the existence check to check if certain tokens exist in a file. If any do, it outputs a message and an error level, how these look depends if you use vale on the command line, or as an Atom or Visual Studio Code extension.

You can also override the level in the .vale.ini file:

vale.Annotations = warning

Spelling

Vale supports spell checking with the spelling check and an in-built U.S. English Hunspell Dictionary that you can override to support other languages. Here's the configuration we use:

extends: spelling
message: "Did you really mean '%s'?"
level: error
ignore: vale-styles/ttd/tech/vocab.txt

You can create a list of words that you don't want vale to flag as an error by adding a file in the ignore property.

Future Tense

This test is still in progress and is currently simplified, but again uses the existence check to look for certain tokens:

extends: existence
message: "Possible future tense ??"
ignorecase: true
level: error
tokens:
  - will
Testing

Opinions expressed by DZone contributors are their own.

Related

  • AI-Powered CI Test Failure Triage
  • When a Coding Agent Fixes the Test Instead of the Bug
  • Testing Java and Spring Applications With Kotlin: Low-Risk to Adoption
  • Your Visual Regression Suite Is Mostly Testing Anti-Aliasing

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook