cfinke / Typo.js

A client-side JavaScript spellchecker that uses Hunspell-style dictionaries.
Other
501 stars 110 forks source link

The suggest function does not seem to suggest words with hyphen correctly #80

Closed tytosecode closed 1 year ago

tytosecode commented 1 year ago

E.g:

.dic file contains: wi-fi spell-check line-break

.aff file is empty.

Expected behaviour: wifi -> Suggest [wi-fi] spellcheck -> Suggest [spell-check] linebreak -> Suggest [line-break]

Actual behaviour: wifi -> Suggest [] spellcheck -> Suggest [] linebreak -> Suggest []

The suggestions work as intended when using the hunspell 1.7.0 cmd with the same .dic and .aff setup. Am I missing anything?

tytosecode commented 1 year ago

Taken from this stackoverflow answer:

Seems that the alphabet is staticly determined in this line.

Below that line there's a commented out section of code that takes the alphabet from the dictionary, why was it commented out and can this be corrected? Alternatively can more symbols be added to the alphabet such as hyphen?

cfinke commented 1 year ago

I believe that section was commented out because it turned out that it took a very very long time to run for certain languages. Looking at it now, it's a pretty naive solution, so I'm sure there is a better way to do what I was trying to accomplish (get a list of the unique letters in a file), but the quick solution would be to just add a hyphen to the alphabet string.

cfinke commented 1 year ago

Additionally, it doesn't look like the English dictionary file included with Typo even has any words that include hyphens, so even if the old method of constructing the alphabet was used, it wouldn't solve this problem.