PyWordNet 2.0
After a spate of requests and a contribution from Wei-Hao Lin, I’ve finally gotten around to releasing an update of PyWordNet that works with the WordNet 2.0 database files. (WordNet 2.0 adds lexical links for derivational morphology and topical classification. This broke the PyWordNet 1.4 dictionary file parser.)
This release also adds a module, contributed by Des Berry, for reading the concordance data; and an implementation of Lexname by Klaus Reis. I don’t know how these work, so ask for help on the PyWordNet discussion group, or from the authors.
PyWordNet is an OO and command-line interface to the WordNet lexical database. PyWordNet lets you manipulate words and senses thus:
>>> N['dog']
dog(n.)
>>> N['dog'].getSenses()
('dog' in {noun: dog, domestic dog, Canis familiaris},
'dog' in {noun: frump, dog}, 'dog' in {noun: dog},
'dog' in {noun: cad, bounder, blackguard, dog, hound, heel},
'dog' in {noun: pawl, detent, click, dog},
'dog' in {noun: andiron, firedog, dog, dogiron})
>>> dog.pointerTargets(MEMBER_MERONYM)
[{noun: Canis, genus Canis}, {noun: pack}]
With the included wntools module, you can also compute meets and joins on words, and use the dictionary for quick-and-dirty stemming:
>>> meet(N['dog'][^0], N['cat'][^0])
{noun: carnivore}
>>> meet(N['dog'][^0], N['person'][^0])
{noun: organism, being}
>>> meet(N['thought'][^0], N['belief'][^0])
{noun: content, cognitive content, mental object}
>>> morphy('dogs')
'dog'
>>> morphy('churches')
'church'
>>> morphy('aardwolves')
'aardwolf'
>>> morphy('abaci')
'abacus'
As before, PyWordNet is available from SourceForge.