|
|
Log in / Subscribe / Register

Improving writing with proselint

By Jonathan Corbet
March 9, 2016
Here at LWN, we put a lot of effort into the quality of our writing, so our attention is naturally drawn to tools that might help the writing process. Recently, links to the proselint tool made the rounds, so it made sense to take a look. What we found was a tool that shows some potential, but quite a bit of work will be needed to get it to where it aspires to be.

What is this project's goal? The word from the front page of its web site is:

With time, proselint will become fast, precise, exhaustive, and authoritative. Eventually, it will be unthinkable to write without it by your side.

Installation of proselint is simple; like many Python utilities, it seems to have bypassed the ordinary distribution channels and can be installed directly with pip. It is a command-line tool; running it on a text file will, by default, result in any warnings being written to the standard output. This is clearly not the expected use, though; it is more likely that proselint will be integrated into other tools that can present its advice in a more friendly manner. To help make this integration easy, proselint can be asked to format its output as JSON rather than plain text.

As a result, it is easy to use proselint as part of the Emacs Flycheck mode, for example; it is a simple matter of adding a few lines to the .emacs file. Once a buffer has been put into flycheck-mode, the text therein will be occasionally checked for problematic English, and the offending text will be highlighted; hovering over that text with the pointer will yield the associated message.

Your editor went searching for some high-quality text to test this tool against. After pondering the classics from Project Gutenberg, the GNU Manifesto, and Trump speech transcripts, the search settled a little closer to home — the kernel's documentation directory. Playing with the Flycheck integration in Emacs quickly yielded results like this:

[Emacs with proselint]

That is good advice indeed, but, in truth, most of what comes out of proselint is less helpful. By far the bulk of the warnings are either (1) using both one and two spaces after a period, or (2) failure to use curly quotes. Neither warning is all that helpful for a writer who was hoping for, as the web site promises, "the world’s greatest writers and editors by your side, where they whisper suggestions on how to improve your prose". Instead, it feels a bit more like one of the world's worst elementary-school teachers criticizing you in front of the entire class about irrelevant details.

But, then, proselint is a new tool, so there is hope for the future. The success of such a tool depends on two things: the rules it uses to analyze text, and the flexibility of the engine that interprets those rules. The rules themselves are written as Python code; here, for example, is the core of the rule that generated the message shown above:

    @memoize
    def check_very_damn(text):
        err = "twain.damn"
        msg = ("Substitute 'damn' every time you're "
               "inclined to write 'very;' your editor will delete it "
               "and the writing will be just as it should be.")
        regex = "very"

        return existence_check(text, [regex], err, msg, max_errors=1)

There are various other functions for performing checks on text, but they all have the same core nature: they are applying regular expressions to the text as a way of triggering rules. That makes rules relatively easy to write, but also limits how smart the tool can actually be. It can readily pick out specific words or combinations of words, but will be hard pressed to offer advice that requires a deeper understanding of the subject text.

A look at the code shows that some thought has been put into making the core engine smarter; there are stubs for functions that can extract specific amounts of context or try to determine what the topic of a range of text is, for example. But stubs is all they are at this point; a lot of work will need to be filled in before this tool can come close to the ambitious goals its developers have set.

One can only wish them luck. There is a lot of advice for writers out there, but it can be hard to even read it all, much less keep it all in mind when actually writing or editing a piece of text. If it were possible to distill a significant part of that advice into a form where it could be applied automatically, the result might be better writing all around. That is a result that one could be damn happy about.


to post comments

Improving writing with proselint

Posted Mar 10, 2016 13:32 UTC (Thu) by pabs (subscriber, #43278) [Link]

There was some talk in the HN thread of them using machine learning stuff for the harder things:

https://news.ycombinator.com/item?id=11232882

Improving writing with proselint

Posted Mar 13, 2016 1:47 UTC (Sun) by vonbrand (guest, #4458) [Link] (1 responses)

The hoary diction tools have served me well, without the "nitpicky primary teacher looking over my shoulder" feel. Probably because they don't try to look smart and failing miserably. Very nice for English, but useless if you primarily write in Spanish.

Improving writing with proselint

Posted Mar 17, 2016 16:21 UTC (Thu) by nhasan (guest, #1699) [Link]

"Trump speech transcript"? Must have generated a lot of errors that were caught by "find hate" rule.

Improving writing with proselint

Posted Mar 19, 2016 1:46 UTC (Sat) by xtifr (guest, #143) [Link] (1 responses)

Oh god no! Yes, there's a lot of writing advice out there, and most of it is bad! Anyone can write a book of writing advice, and they tend to sell very well, so lots of people with no qualifications write them. And writers are notoriously bad at analyzing their own writing. Books of writing advice from professional authors are often filled with rules that the author never actually follows in his or her writing. Usually because it's terrible advice! Over on Language Log (a friendly blog run by a group of top-tier linguists), they regularly feature advice books where the author breaks numerous rules while writing the first paragraph of the introduction! (Which is not to say that the introductions are poorly written—far from it!)

Anyone want to take any bets on how often the word "very" actually appears in Twain's writing? Or the works of other great writers?

As for trying to apply the (frequently bad) advice programmatically? Just no.

There was a recent program which tried to do something similar (slightly more sophisticated, I think, but just as badly based on blind pattern matching), called "Hemingway". It was absolutely shredded over at Language Log. The program named for Hemingway claims that Hemingway is a terrible writer...

(Note that some people suggested that the Hemingway app might have been aimed at technical writing, so I tested it on K&R, with predictably bad/stupid results, as I discussed in the comments there.)

Improving writing with proselint

Posted Mar 19, 2016 2:53 UTC (Sat) by bfields (subscriber, #19510) [Link]

Anyone want to take any bets on how often the word "very" actually appears in Twain's writing?

Well, how can one possible ignore that question?: grep finds that of the 2.8 million words in http://www.gutenberg.org/ebooks/3200.txt.utf-8, 3364 are "very". Is that a lot or a little?

Looking at some examples.... I dunno, I think his advice still holds for a lot of them. Maybe he could have used the reminder.


Copyright © 2016, Eklektix, Inc.
This article may be redistributed under the terms of the Creative Commons CC BY-SA 4.0 license
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds