I'm trying to add Typo Tolerance to a search bar, and I found an npm package called typo-js to help with it. However, it required a Hunspell Dictionary to work, and I haven't been able to find any online resources that explain what that is, or how to implement it in the code. I've included the link to the package below. Any insights on how to resolve this problem would be appreciated.
https://www.jsdelivr.com/package/npm/typo-js
I'm not sure where to find the files it's asking for, or what to do with them once I obtain them.
The answer depends if you are using
typo-jsclientside (frontend FE) or serverside (backend BE)Your question suggests FE, so I'll answer accordingly
First, you need an AFF file and a DIC file for your language
For example:
you can find these files in, for example:
https://www.npmjs.com/package/dictionary-en-gb
(you can use https://unpkg.com to download just these 2 files or you can
npm install dictionary-en-gband copy paste the files from thenode_modulesfolder (and then uninstall it - if you like))these files should be placed in your public/assets folder so that they can be loaded over HTTP
Finally:
Note that
typo-jsis very fussy where it looks for these files and only thedictionaryPathsetting gives a degree of control.Code annotation states these files will be loaded from:
[settings.dictionaryPath]/dictionaries/[dictionary]/[dictionary].aff[settings.dictionaryPath]/dictionaries/[dictionary]/[dictionary].dicIn this example, the files should be located at:
If it's not finding the files, keep an eye on your browser's network tab to see where it is trying to load them from (and locate the files accordingly).