2

I have 2 files in hunspell format(.dic and .aff) for Ukrainian language. My program has to get base form of the input word. So, it can use word form from .dic file and affices from .aff files. I don't know how to achieve this even with Hunspell util, but suppose it is possible.

Which python libraries can get base form of the word using .dic and .aff files?

olha
  • 2,132
  • 1
  • 18
  • 39

2 Answers2

3

As said before hunspell is the library you require. Examples from https://code.google.com/p/pyhunspell/wiki/UsingPyHunspell:

import hunspell
hobj = hunspell.HunSpell('/usr/share/myspell/en_US.dic', '/usr/share/myspell/en_US.aff')
hobj.spell('spookie')
>>>>False

hobj.suggest('spookie')
>>>>['spookier', 'spookiness', 'spooky', 'spook', 'spoonbill']

hobj.spell('spooky')
>>>>True

hobj.analyze('linked')
>>>>[' st:link fl:D']
hobj.stem('linked')
>>>>['link']
GAM PUB
  • 218
  • 4
  • 11
  • Do you know how to add new words to the dictionary? There is an add() function in the C source of pyhunspell, but there is no explanation on the usage and arguments. – imrek Aug 10 '15 at 08:08
0

Just an update to say that le pyhunspell project is no longer on googlecode. Here are the new links:

As for the add function (mentionned in comment of first answer), it is now documented in the pydoc.

Benoît Latinier
  • 2,062
  • 2
  • 24
  • 36