0

I have a large text file of an OCR'd book where many words have been broken and hyphenated at the end of a line. Eg.

In his newest book of language ex- 
ploration, Professor Asimov ranges over 

I can see many ways I might go about cleaning up the file of these particular errors but believe the process would go much faster if I were able to compose a regex that can find a misspelled word.

Is it possible to specify a regex for a misspelled word. I suspect not, but thought I'd ask anyway.

[Edit]

And by cleaning up the file I mean correcting spelling, formatting etc.

Since posting I've tried out aspell but couldn't get it to give me line-numbers (in non-interactive mode); and vim plugin SpellCheck.

The latter works as described and is actually pretty good (despite requiring a 1MB library.

It would still be cool if I could write a regex for misspelled words though.

7
  • 1
    Welcome to the forum! Could you clarify what you mean by "cleaning the file"? What are you exactly trying to achieve? Do you need to undo the break for these words?
    – Biggybi
    Feb 6, 2021 at 9:34
  • There cannot exist a regex to find all misspelled words.
    – guntbert
    Feb 6, 2021 at 19:36
  • OK, but my question was a regex for a misspelled word. :smile:
    – Tom
    Feb 7, 2021 at 2:51
  • 1
    If I’ve understood you correctly, you’re after a regex which will match any word which vim has marked as incorrectly spelt. That’s not possible as the regular expression engine doesn’t have an atom for accessing that kind of information; of course you could always write a function on-the-fly to query all misspelt words in a document and compile them into one long regex but that might be a case of XY problem. Feb 8, 2021 at 10:49
  • 1
    Also, apologies if you already know this but when you say you have to mash the keys to move from one spelling error to another, you are aware that you can use ]s? Feb 8, 2021 at 10:50

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.