1
2
3
4
5
6
7
8
9
10 """
11 Wordnet interface, based on Oliver Steele's Pywordnet, together
12 with an implementation of Ted Pedersen's Wordnet::Similarity package.
13
14 Usage
15 =====
16
17 >>> from nltk.wordnet import *
18
19 Retrieve words from the database
20
21 >>> N['dog']
22 dog (noun)
23 >>> V['dog']
24 dog (verb)
25 >>> ADJ['clear']
26 clear (adj)
27 >>> ADV['clearly']
28 clearly (adv)
29
30 Examine a word's senses and pointers:
31
32 >>> N['dog'].synsets()
33 [{noun: dog, domestic_dog, Canis_familiaris}, {noun: frump, dog}, {noun: dog}, {noun: cad, bounder, blackguard, dog, hound, heel}, {noun: frank, frankfurter, hotdog, hot_dog, dog, wiener, wienerwurst, weenie}, {noun: pawl, detent, click, dog}, {noun: andiron, firedog, dog, dog-iron}]
34 ('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: frank, frankfurter, hotdog, hot dog, dog, wiener, wienerwurst, weenie}, 'dog' in {noun: pawl, detent, click, dog}, 'dog' in {noun: andiron, firedog, dog, dog-iron})
35
36 Extract the first sense:
37
38 >>> N['dog'][0]
39 {noun: dog, domestic_dog, Canis_familiaris}
40
41 Get the first five pointers (relationships) from dog to other synsets:
42
43 >>> N['dog'][0].relations()
44 {'hypernym': [('noun', 2083346, 0), ('noun', 1317541, 0)],
45 'part holonym': [('noun', 2158846, 0)],
46 'member meronym': [('noun', 2083863, 0), ('noun', 7994941, 0)],
47 'hyponym': [('noun', 1322604, 0), ('noun', 2084732, 0), ...]}
48
49 Get those synsets of which 'dog' is a member meronym:
50
51 >>> N['dog'][0][MEMBER_MERONYM]
52 [{noun: Canis, genus Canis}, {noun: pack}]
53
54 """
55
56 from util import *
57 from cache import *
58 from lexname import *
59 from dictionary import *
60 from similarity import *
61 from synset import *
62 from browse import *
63 from stemmer import *
64