Create spellfile from hunspell .dic and .aff files

313 views
Skip to first unread message

Froggy

unread,
Apr 25, 2008, 3:37:38 AM4/25/08
to v...@vim.org
I created a file de.utf-8.spl from the latest hunspell .dic and .aff
files after slightly modifying de_DE.aff for vims COMPOUND syntax. I
used

:mkspell de de_DE

So far, everything worked. But now vim does not recognize compound
words very well. For example, "Zusammenhang", a common german word, is
not recognized. Vim suggests "Zusammen0hang" instead. I see that my
newly created dictionary contains many compound words of the form
"firstpart0secondpart". Many of these are displayed when I hit "z=".

I imagine this has to do with the different syntax between hunspell
and the vim spellchecker. The relevant parts of de_DE.dic and
de_DE.aff are (I hope I did not forget anything):

Zusammen/hij
hang/STozm

PFX i Y 1
PFX i 0 -/coyf .

SFX j Y 3
SFX j 0 0/xoc .
SFX j 0 -/zocf .
SFX j 0 -/cz .

PFX m h -H/co h

SFX S Y 1
SFX S 0 s .

SFX T Y 1
SFX T 0 es .

NEEDAFFIX h
NEEDCOMPOUND o
CIRCUMFIX f
COMPOUNDPERMITFLAG c
COMPOUNDRULE xy*z

I don't see what's wrong here. Does anyone else?

Best regards - Froggy

Froggy

unread,
Apr 26, 2008, 3:09:58 AM4/26/08
to v...@vim.org
Hi everyone,

unfortunately, I am still stuck with this problem. Has no one
experienced something like this?

Thank you and best regards - Froggy

Bram Moolenaar

unread,
Apr 28, 2008, 4:31:02 PM4/28/08
to Froggy, v...@vim.org

When I put this through ":mkspell" I get:

Reading affix file test.aff ...
Trailing text in test.aff line 9: h
Expected Y or N in test.aff line 9: h
Defining COMPOUNDPERMITFLAG after PFX item may give wrong results in test.aff li
ne 20
Reading dictionary file test.dic ...
Compressing word tree...
Compressed 3 of 70 nodes; 67 (95%) remaining
Writing spell file test.latin1.spl ...
Done!
Estimated runtime memory use: 335 bytes


This should give you a few hints. Note that Hunspell has different
syntax and semantics for compound rules. It's very complex what
Hunspell does, Vim only supports some things. Check the documentation
of both.

--
ARTHUR: Well, I AM king...
DENNIS: Oh king, eh, very nice. An' how'd you get that, eh? By exploitin'
the workers -- by 'angin' on to outdated imperialist dogma which
perpetuates the economic an' social differences in our society! If
there's ever going to be any progress--
The Quest for the Holy Grail (Monty Python)

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ download, build and distribute -- http://www.A-A-P.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Bert

unread,
May 6, 2008, 4:55:51 PM5/6/08
to v...@vim.org
On Mon, Apr 28, 2008 at 10:31:02PM +0200, Bram Moolenaar wrote:
>
> Froggy (or whatever this shy person is called) wrote:

Sorry, I don't see another way to protect my privacy these times...

> > Zusammen/hij
> > hang/STozm
> >
> > PFX i Y 1
> > PFX i 0 -/coyf .
> >
> > SFX j Y 3
> > SFX j 0 0/xoc .
> > SFX j 0 -/zocf .
> > SFX j 0 -/cz .
> >
> > PFX m h -H/co h
> >
> > SFX S Y 1
> > SFX S 0 s .
> >
> > SFX T Y 1
> > SFX T 0 es .
> >
> > NEEDAFFIX h
> > NEEDCOMPOUND o
> > CIRCUMFIX f
> > COMPOUNDPERMITFLAG c
> > COMPOUNDRULE xy*z
>

> When I put this through ":mkspell" I get:
>
> Reading affix file test.aff ...
> Trailing text in test.aff line 9: h
> Expected Y or N in test.aff line 9: h
> Defining COMPOUNDPERMITFLAG after PFX item may give wrong results in test.aff li
> ne 20
> Reading dictionary file test.dic ...
> Compressing word tree...
> Compressed 3 of 70 nodes; 67 (95%) remaining
> Writing spell file test.latin1.spl ...
> Done!
> Estimated runtime memory use: 335 bytes
>
>
> This should give you a few hints. Note that Hunspell has different
> syntax and semantics for compound rules. It's very complex what
> Hunspell does, Vim only supports some things. Check the
> documentation of both.

Thanks for your reply and for testing this. I put the lines in
the .aff file in the right order, like this:

============= test.aff ================


SFX j Y 3
SFX j 0 0/xoc .
SFX j 0 -/zocf .
SFX j 0 -/cz .

SFX S Y 1


SFX S 0 s .

SFX T Y 1
SFX T 0 es .

NEEDAFFIX h
NEEDCOMPOUND o
CIRCUMFIX f
COMPOUNDPERMITFLAG c
COMPOUNDRULE xy*z

PFX i Y 1


PFX i 0 -/coyf .

PFX m Y 1


PFX m h -H/co h

=======================================

============= test.dic ================
2
Zusammen/hij
hang/STozm
=======================================

When I call ":mkspell de test", vim does not complain:

============= vim output ==============


Reading affix file test.aff ...

Reading dictionary file test.dic ...
Compressing word tree...

Compressed 6 of 90 nodes; 84 (93%) remaining
Writing spell file de.utf-8.spl ...
Done!
Estimated runtime memory use: 420 bytes
=======================================

I also checked vims documentation, and test.aff seems to conform to
the rules. But still, a "spelldump" yields that the resulting
dictionary only contains a single word: "Zusammen-".

I just don't see the mistake here :-(

Best, Bert [At least a "proper" name this time :-)]

Bram Moolenaar

unread,
May 9, 2008, 4:05:07 PM5/9/08
to Bert, v...@vim.org

Bert wrote:

> On Mon, Apr 28, 2008 at 10:31:02PM +0200, Bram Moolenaar wrote:
> >
> > Froggy (or whatever this shy person is called) wrote:
>
> Sorry, I don't see another way to protect my privacy these times...

Privacy when reporting a problem? I like to know who I'm talking to.
At least so I can find this message in my huge email archive.

You need to put the definition of flags (NEEDAFFIX et al.) before where
they are used. I suppose ":mkspell" should give you a warning about
that.

It looks overcomplicated. Why to you require the "i" prefix for
Zusammen? This way Zusammen as a single word is not allowed.

Perhaps you can explain what you are trying to accomplish here. What
are the valid words you are defining?

--
If "R" is Reverse, how come "D" is FORWARD?

Reply all
Reply to author
Forward
0 new messages