help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Hunspell and contractions with apostrophes


From: Dmitry Alexandrov
Subject: Re: Hunspell and contractions with apostrophes
Date: Wed, 27 May 2020 03:23:16 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Eric Abrahamsen <eric@ericabrahamsen.net> wrote:
> I've battled with this for years now: Hunspell marks any contraction with an 
> apostrophe (eg the "I've" that starts this sentence) as misspelled.

Iʼd say that this is an obvious bug in the dictionary, that should be reported.

FWIW, it is present in Debian 10 as well:

        $ HOME=/tmp DICPATH='' hunspell -d en_US
        Hunspell 1.7.0
        I've
        *
        & ve 15 2: be, v, e, eve, vie, ave, vet, veg, Eve, Ave, vs, vi, re, me, 
he

and Iʼve never noticed it only because I use en_GB dictionary, which is fine:

        $ HOME=/tmp DICPATH='' hunspell -d en_GB
        Hunspell 1.7.0
        I've
        *

> It used to be that I could edit /usr/share/hunspell/en_US.aff and add the 
> apostrophe to WORDCHARS (and also "ICONV ’ '")

First and foremost, your ’ is *not* an apostrophe, itʼs a right quote.  
Apostrophe is ʼ.

This does matter, just check how do word-moving commands act on weird “I’ve” vs 
proper “Iʼve” and ascii (but no less proper) “I've”.

> and that would do it. Until the next time the hunspell package updated, and 
> over-wrote its config files (I'm running Arch linux), and I would have to do 
> it again.

Sure.  You are not supposed to tamper with files under package management.  Put 
your customized dictionaries somewhere else (in /etc, in your home directory).  
I do not remember, whether hunspell(1) have any non-/usr paths hardcoded, but 
these lines in my ~/.profile suggest, that it does not:

        if [ -z "$DICPATH" ]; then
            if [ -d '/usr/share/hunspell' ]; then
                DICPATH='/usr/share/hunspell'
            fi
        fi
        
        if [ -d "$HOME/.share/hunspell" ]; then
            DICPATH="$HOME/.share/hunspell:$DICPATH"
        fi
        
        if [ -d "$HOME/.local/share/hunspell" ]; then
            DICPATH="$HOME/.local/share/hunspell:$DICPATH"
        fi
        
        export DICPATH

> As of six months or a year or so ago, that trick no longer works.

It seems, that the question have changed in meanwhile.  Whether a right single 
quote is recognized as apostrophe is orthogonal to whether “I've” is recognized 
as a correct English word.

Things like “I've” or “I'm” are normally explicitly mentioned in the dictionary 
(since something like “pointʼve” is not entirely okay, afaiu).

If they are there, then double-check, that the used affix file does have 
apostrophe among WORDCHARS:

        WORDCHARS 0123456789'

(Thatʼs what is wrong with en_US.aff in Debian.)

If “I've” had still been recognized as a mistake, that would be pretty odd.


Now to Unicode.

Make sure, that the affix file correctly declares its encoding:

        SET UTF-8

Make Unicode apostrophe recognized as apostrophe:

        ICONV 1
        ICONV ʼ '

Optionally, make Unicode preferred to ASCII one for suggestions:

        OCONV 1
        OCONV ' ʼ


Now to Emacs.

If all of the above works with hunspell(1) itself, no configurations besides 
(setq ispell-program-name "hunspell") should be required.

I you insist on using right single quote as apostrophe, though, I have no idea, 
how to make ispell.el pass it to hunspell(1) as a part of a word.  Neither why 
ever do that.

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]