Rebuilding the spellchecker
zverok.github.io
zverok.github.io
It's amazing how difficult it is to encode rules for dealing with natural language, considering how easy it is for a person to resolve ambiguities, misspellings, and the like. Of course, we forget how much knowledge we have encoded in our own brains.
I'm trying to do named entity recognition for chemicals and materials in quasi-natural language texts that we've developed over many years at work. It's brutal.
What if any open source projects would implement the corresponding functionality? Also would anybody have experience with this?
I have a distant dream of doing to it what I did to Hunspell (write a code/series of articles explaining how it works and why it is so hard), but we'll see.
For what I know, LanguageTool is based just on a huge set of rules (you can see them in the repo[1]); and Grammarly is a mix of rule-based and machine-learning suggestions (I heard a rumor that it is 99% rule-based, and talks about ML are mostly marketing, but I don't know how reliable this rumor was).
1: https://github.com/languagetool-org/languagetool/tree/master...
https://github.com/victorqribeiro/goSpellcheck
I wrote this originally in python, then I ported it to go. Back then I had plans to improve it. I believe that the most erros would be due to miss press of keys. I was sketching an algorithm to find similar words given a dictionary. Soon I had to deal with other projects (from college) and I let the spellcheck to the smart people.
> Learn how to spell, or use a spell-checker!
Why would I use a spell-checker, am I Gandalf?
But of course, something that actually worked like that would be indistinguishable from magic.
I think Grammarly isn't even top 5 in checking grammar tools or top 10 in helping improve style.
I think the problem for grammar checkers is that they are designed to help nonnative English speakers is vastly larger than the problem of helping native English speakers, and no grammar checker I am aware of does much to help ESL speakers who are not already fluent in English.
Also Rahul (founder of Superhuman) said there is not currently an automatic spell/grammar check library that developers could use to integrate in apps and software they create. “When you type I would love to be able to autocorrect errors in your typing in the same way the MacOS does natively", so there is maybe an opportunity out there ! Don't forget me if you make it through x) and I'm spazzed to check your upcoming writings !
What are top 5 tools in checking grammar/improve style?
Are you considering https://github.com/wolfgarbe/SymSpell algo to do suggestions? If I recall native hunspell suggestions are quite slow - the same algo must be even slower on python.
Hehe... Actually, Ruby is my primary language, but I have chosen Python for this project for a complicated set of reasons I tried to explain[0] in the first article.
> If I recall native hunspell suggestions are quite slow - the same algo must be even slower on python.
Pretty slow, yes. But the current project's goal is to "uncover" how the Hunspell works—so, I implement it the Hunspell's way. The next (several) parts of the series would explain a lot on suggest, including "why is it hard", and "why SymSpell might not be enough" ;)
0: https://zverok.github.io/blog/2021-01-05-spellchecker-1.html...
But ML approach will raise a question of data availability. What good your "deep learning OSS spellchecker" will do if there aren't good (and open) models for it which cover as much languages as existing Hunspell dictionaries do? And what if adding a bunch of new words requires laborous model retraining? It is not unsolvable, but non-trivial.
I believe all the giants have something like this inside (I don't think spelling correction in Google search bar is handled with Hunspell, right?), but it is much harder to do as an open tool, ready to embedding into other software.
There are a notable attempts, though: JamSpell for one (https://github.com/bakwc/JamSpell), which has an open "free" models, and more precise commercial ones; source code is open (maybe also only for using "simplistic" models, haven't dug deeper).
SymSpell algorithm (which is quite different, I'll go into it in the next part to some extent) is much easier to port, so there is a JS SymSpell port[3] (which seems abandoned though).
0: https://zverok.github.io/blog/2021-01-05-spellchecker-1.html
1: https://github.com/wooorm/nspell