1

I'm working on a longer prose text and I would like to have some automatic assistance to check my use of past and present tense throughout the text. My usual test suite (aspell, LanguageToolCheck, chktex) does not cover this, and I didn't find another plugin or vim function online that would help me with that. These are some of my ideas how it could look like:

  1. highlight all verbs, so it is easier to check them manually
  2. highlight all verbs and color code their tense
  3. iteratively check my text (like aspell/LanguageToolCheck) and warn me whenever I switch tenses

Is there any tool out there? If not, is there maybe a vim function that recognizes verbs? The text is in English.

6
  • You would need a program that can identify verbs and tenses (maybe some writers or editors have such a thing?) which you could then integrate with Vim. There is no such feature in stock Vim.
    – D. Ben Knoble
    Sep 19 at 12:15
  • What Knoble said. But I doubt verb/tense identification can be done with simple tools. Researchers are still tinkering with languages (NLP) with machine learning. Have you seen any other editor or word-processor with this functionality?
    – kadekai
    Sep 20 at 9:10
  • Ok, I thought so, although with Vim you never know what hidden functionalities it has. I don't know about other word processors that support this, but I found a few websites that seem to offer such a service (e.g., becomeawritertoday.com/verb-tense-checker). But an online service seems a bit impractical for a text with hundreds of pages. It would be great to have something like that directly in Vim. Maybe that could become a project to work on once I'm finished writing. Sep 20 at 16:01
  • One of the difficulties here is that all of these language tools are based on machine learning models, which tend to be very large (tens of GB at the least, years ago a friend of mine worked for one of these services, and he talked about the problems with offering a self-hosted version). Offering a "simple tool" that does this just as well as the online services trained on a lot of real-world data is somewhat tricky. Sep 20 at 21:42
  • Or, ya know, a massive dictionary of conjugated verbs and their tenses :P
    – D. Ben Knoble
    Sep 22 at 19:52

1 Answer 1

0

It is clear there is not a single tool to cover all your requirements. However, I will provide a simple PoC and you can extend this to use different highlight groups for each tense, and maybe add more complex logic to warn you about changed tenses. You need to:

  1. tokenize your document
  2. run a Part-of-speech (POS) tagger
  3. only return verbs (or return pos tags in order to highlight words depending on tense)
  4. call matchadd accordingly

On the vimscript side:

highlight link MyGroup IncSearch
function! HighlightVerbs()
        let result = systemlist('./pos.py', getline(1, '$'))
        for token in result
                call matchadd("MyGroup", '\<' .. token .. '\>')
        endfor
endfunction

For the POS tagger, I used spacy:

#! /usr/bin/env python3

import spacy
import sys

nlp = spacy.load("en_core_web_sm")

unique_words = set()
for line in sys.stdin:
    for word in nlp(line):
        if word.pos_ == 'VERB':
            unique_words.add(word.text)

for w in unique_words:
    print(w)

It should work as follows:

enter image description here

1
  • 1
    Thanks, this looks like it works quite well for a quick scan. I'll try it out Sep 24 at 6:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.