Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Hunspell always treats single quote characters (apostrophes) as part of the word. That means that when text uses single quotes for quoting, hunspell flags those as errors. Even a single quote all by itself is considered a (misspelled) word.

% echo "He asked, 'Why can't I quote?'" | hunspell
Hunspell 1.3.2
*
*
& 'Why 3 10: why, whey, whiny
*
*
*
& ' 15 29: 's, e, s, i, a, n, r, t, o, l, c, d, u, g, m

Aspell gets this right:

% echo "He asked, 'Why can't I quote?'" | aspell -a
@(#) International Ispell Version 3.1.20 (but really Aspell 0.60.7-20110707)
*
*
*
*
*
*

I would prefer to use hunspell, but to direct it to ignore leading and trailing single quote characters, while retaining embedded quote characters such as that in "can't".

How can I do this?

share|improve this question

2 Answers 2

Delete every ' that is followed by a non-alphanumeric, or preceded by a non-alphanumeric, or at the beginning or at the end of a line:

echo "He asked, 'Why can't I quote?'" | perl -pe 's/'"'"'(\W)/$1/g;s/(\W)'"'"'/$1/g;s/^'"'"'//;s/'"'"'$//;' | hunspell
share|improve this answer
    
Thanks for the suggestion, but this does not help me. I'm looking for a way to change hunspell, not to change the input to hunspell. Changing the string throws off the column numbers in the hunspell output. That means that the hunspell output no longer maps to the original string, so it cannot be used programmatically without a lot of extra bookkeeping. –  mernst Apr 29 '13 at 6:16
    
OK, I see the problem. I assume that you can achieve that patching the hunspell dictionaty files. There's an "IGNORE characters" option documented in hunspell4.pdf, but I've never tried that. Alternatively, you could use an input conversion that replaces quotes by spaces, rather than deleting them, so that column numbers are left unchanged: perl -pe 's/'"'"'(\W)/ $1/g;s/(\W)'"'"'/$1 /g;s/^'"'"'/ /;s/'"'"'$/ /;' –  Uwe Apr 29 '13 at 6:42

You need to add the following line to your dictionary affix file (i.e. /usr/share/hunspell/en_US.aff)

IGNORE '

Unfortunately I did not figure out a way to specify a personal affix file like you can do with a personal dictionary file.

share|improve this answer
    
I tried this, and it did not change the behavior. –  mernst Sep 29 at 12:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.