1WNUTIL(3) WordNet™ Library Functions WNUTIL(3)
2
3
4
6 wninit, re_wninit, cntwords, strtolower, ToLowerCase, strsubst, getptr‐
7 type, getpos, getsstype, StrToPos, GetSynsetForSense, GetDataOffset,
8 GetPolyCount, WNSnsToStr, GetValidIndexPointer, GetWNSense, GetSenseIn‐
9 dex, default_display_message - utility functions used by the interface
10 code
11
13 #include "wn.h"
14
15 int wninit(void);
16
17 int re_wninit(void);
18
19 int cntwords(char *str, char separator);
20
21 char *strtolower(char *str);
22
23 char *ToLowerCase(char *str);
24
25 char *strsubst(char *str, char from, char to);
26
27 int getptrtype(char *ptr_symbol);
28
29 int getpos(char *ss_type);
30
31 int getsstype(char *ss_type);
32
33 int StrToPos(char **pos);
34
35 SynsetPtr GetSynsetForSense(char *sense_key);
36
37 long GetDataOffset(char *sense_key);
38
39 int GetPolyCount(char *sense_key);
40
41 char *WNSnsToStr(IndexPtr idx, int sense_num);
42
43 IndexPtr GetValidIndexPointer(char *str, int pos);
44
45 int GetWNSense(char *lemma, *lex_sense);
46
47 SnsIndexPtr GetSenseIndex(char *sense_key);
48
49 int GetTagcnt(IndexPtr idx, int sense);
50
51 int default_display_message(char *msg);
52
54 The WordNet library contains many utility functions used by the inter‐
55 face code, other library functions, and various applications and tools.
56 Only those of importance to the WordNet search code, or which are gen‐
57 erally useful are described here.
58
59 wninit() opens the files necessary for using WordNet with the WordNet
60 library functions. The database files are opened, and morphinit() is
61 called to open the exception list files. Returns 0 if successful, -1
62 otherwise. The database and exception list files must be open before
63 the WordNet search and morphology functions are used. If the database
64 is successfully opened, the global variable OpenDB is set to 1. Note
65 that it is possible for the database files to be opened (OpenDB == 1),
66 but not the exception list files.
67
68 re_wninit() is used to close the database files and reopen them, and is
69 used exclusively for WordNet development. re_morphinit() is called to
70 close and reopen the exception list files. Return codes are as
71 described above.
72
73 cntwords() counts the number of underscore or space separated words in
74 str. A hyphen is passed in separator if is is to be considered a word
75 delimiter. Otherwise separator can be any other character, or an
76 underscore if another character is not desired.
77
78 strtolower() converts str to lower case and removes a trailing adjec‐
79 tive marker, if present. str is actually modified by this function,
80 and a pointer to the modified string is returned.
81
82 ToLowerCase() converts str to lower case as above, without removing an
83 adjective marker.
84
85 strsubst() replaces all occurrences of from with to in str and returns
86 resulting string.
87
88 getptrtype() returns the integer ptr_type corresponding to the pointer
89 character passed in ptr_symbol. See wnsearch(3) for a table of pointer
90 symbols and types.
91
92 getpos() returns the integer constant corresponding to the synset type
93 passed. ss_type may be one of the following: n, v, a, r, s. If s is
94 passed, ADJ is returned. Exits with -1 if ss_type is invalid.
95
96 getsstype() works like getpos(), but returns SATELLITE if ss_type is s.
97
98 StrToPos() returns the integer constant corresponding to the syntactic
99 category passed in pos. string must be one of the following: noun,
100 verb, adj, adv. -1 is returned if pos is invalid.
101
102 GetSynsetForSense() returns the synset that contains the word sense
103 sense_key and NULL in case of error.
104
105 GetDataOffset() returns the synset offset for synset that contains the
106 word sense sense_key, and 0 if sense_key is not in sense index file.
107
108 GetPolyCount() returns the polysemy count (number of senses in WordNet)
109 for lemma encoded in sense_key and 0 if word is not found.
110
111 WNSnsToStr() returns sense key encoding for sense_num entry in idx.
112
113 GetValidIndexPointer() returns the Index structure for word in pos.
114 Calls morphstr(3) to find a valid base form if word is inflected.
115
116 GetWNSense() returns the WordNet sense number for the sense key encod‐
117 ing represented by lemma and lex_sense.
118
119 GetSenseIndex() returns parsed sense index entry for sense_key and NULL
120 if sense_key is not in sense index.
121
122 GetTagcnt() returns the number of times the sense passed has been
123 tagged according to the cntlist file.
124
125 default_display_message() simply returns -1. This is the default value
126 for the global variable display_message, that points to a function to
127 call to display an error message. In general, applications (including
128 the WordNet interfaces) define an application specific function and set
129 display_message to point to it.
130
132 include/wn.h lists all the pointer and search types and their corre‐
133 sponding constant values. There is no description of what each search
134 type is or the results returned. Using the WordNet interface is the
135 best way to see what types of searches are available, and the data
136 returned for each.
137
139 wnintro(3), wnsearch(3), morph(3), wnintro(5), wnintro(7).
140
141
143 Error checking on passed arguments is not rigorous. Passing NULL
144 pointers or invalid values will often cause an application to die.
145
146
147
148WordNet 3.0 Dec 2006 WNUTIL(3)