cfinke / Typo.js

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

Words with punctuation should not count as misspellings #1

Closed dbolton closed 13 years ago

dbolton commented 13 years ago

//sentence punctuation such as comma, colon, semi-colon, period, exclamation mark, question mark, etc. should be ignored var is_spelled_correctly = dictionary.check("word,") //should be true, but returns false

dbolton commented 13 years ago

It case it is helpful here is a list of punctuation that I am using to work around this issue (it includes non-English punctuation too):

,.?¿!¡;:'"‘’“”‚„‹›«»–— *†‡

Here's my actual line of code:

word = word.replace(/(^[,.?¿!¡;:'"‘’“”‚„‹›«»–— †‡]|[,.?¿!¡;:'"‘’“”‚„‹›«»–— †‡]$)/g,""); //trim off any punctuation (without removing apostrophes from the middle of the word)

cfinke commented 13 years ago

I think, but I am not convinced, that removing all punctuation is outside the realm of what Typo should be doing. In looking through the source of Hunspell, I don't see any references to sanitizing words outside of leading/trailing whitespace and trailing periods: http://hunspell.cvs.sourceforge.net/viewvc/hunspell/hunspell/src/hunspell/hunspell.cxx?view=markup

dbolton commented 13 years ago

I've not worked with spell checking before (from a programming side). So I don't know the expectations. Feel free to close if needed.

Shiyazudeen commented 7 years ago

This is very much needed while implementing custom spell checkers and word suggestions. Any idea if this one is resolved or if there is any work around?