1 /*
2 
3    wn.h - header file needed to use WordNet Run Time Library
4 
5    $Id: wn.h,v 1.55 2002/03/07 18:44:40 wn Rel $
6 
7 */
8 
9 #ifndef _WN_
10 #define _WN_
11 
12 #include "wnconsts.h"
13 #include "wntypes.h"
14 #include "wnglobal.h"
15 #include "wnrtl.h"
16 
17 /* Make all the functions compatible with c++ files */
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
22 /* External library function prototypes */
23 
24 /*** Search and database functions (search.c) ***/
25 
26 /* Primry search algorithm for use with user interfaces */
27 extern char *findtheinfo(char *, int, int, int);
28 
29 /* Primary search algorithm for use with programs (returns data structure) */
30 extern SynsetPtr findtheinfo_ds(char *, int, int, int);
31 
32 /* Set bit for each search type that is valid for the search word
33    passed and return bit mask. */
34 extern unsigned int is_defined(char *, int);
35 
36 /* Set bit for each POS that search word is in.  0 returned if
37    word is not in WordNet. */
38 extern unsigned int in_wn(char *, int);
39 
40 /* Find word in index file and return parsed entry in data structure.
41    Input word must be exact match of string in database. */
42 extern IndexPtr index_lookup(char *, int);
43 
44 /* 'smart' search of index file.  Find word in index file, trying different
45    techniques - replace hyphens with underscores, replace underscores with
46    hyphens, strip hyphens and underscores, strip periods. */
47 extern IndexPtr getindex(char *, int);
48 extern IndexPtr parse_index(long, int, char *);
49 
50 /* Read synset from data file at byte offset passed and return parsed
51    entry in data structure. */
52 extern SynsetPtr read_synset(int, long, char *);
53 
54 /* Read synset at current byte offset in file and return parsed entry
55    in data structure. */
56 extern SynsetPtr parse_synset(FILE *, int, char *);
57 
58 /* Free a synset linked list allocated by findtheinfo_ds() */
59 extern void free_syns(SynsetPtr);
60 
61 /* Free a synset */
62 extern void free_synset(SynsetPtr);
63 
64 /* Free an index structure */
65 extern void free_index(IndexPtr);
66 
67 /* Recursive search algorithm to trace a pointer tree and return results
68    in linked list of data structures. */
69 SynsetPtr traceptrs_ds(SynsetPtr, int, int, int);
70 
71 /* Do requested search on synset passed, returning output in buffer. */
72 extern char *do_trace(SynsetPtr, int, int, int);
73 
74 /*** Morphology functions (morph.c) ***/
75 
76 /* Open exception list files */
77 extern int morphinit();
78 
79 /* Close exception list files and reopen */
80 extern int re_morphinit();
81 
82 /* Try to find baseform (lemma) of word or collocation in POS. */
83 extern char *morphstr(char *, int);
84 
85 /* Try to find baseform (lemma) of individual word in POS. */
86 extern char *morphword(char *, int);
87 
88 /*** Utility functions (wnutil.c) ***/
89 
90 /* Top level function to open database files, initialize wn_filenames,
91    and open exeception lists. */
92 extern int wninit();
93 
94 /* Top level function to close and reopen database files, initialize
95    wn_filenames and open exception lists. */
96 extern int re_wninit();
97 
98 /* Count the number of underscore or space separated words in a string. */
99 extern int cntwords(char *, char);
100 
101 /* Convert string to lower case remove trailing adjective marker if found */
102 extern char *strtolower(char *);
103 
104 /* Convert string passed to lower case */
105 extern char *ToLowerCase(char *);
106 
107 /* Replace all occurrences of 'from' with 'to' in 'str' */
108 extern char *strsubst(char *, char, char);
109 
110 /* Return pointer code for pointer type characer passed. */
111 extern int getptrtype(char *);
112 
113 /* Return part of speech code for string passed */
114 extern int getpos(char *);
115 
116 /* Return synset type code for string passed. */
117 extern int getsstype(char *);
118 
119 /* Reconstruct synset from synset pointer and return ptr to buffer */
120 extern char *FmtSynset(SynsetPtr, int);
121 
122 /* Find string for 'searchstr' as it is in index file */
123 extern char *GetWNStr(char *, int);
124 
125 /* Pass in string for POS, return corresponding integer value */
126 extern int StrToPos(char *);
127 
128 /* Return synset for sense key passed. */
129 extern SynsetPtr GetSynsetForSense(char *);
130 
131 /* Find offset of sense key in data file */
132 extern long GetDataOffset(char *);
133 
134 /* Find polysemy (collins) count for sense key passed. */
135 extern int GetPolyCount(char *);
136 
137 /* Return word part of sense key */
138 extern char *GetWORD(char *);
139 
140 /* Return POS code for sense key passed. */
141 extern int GetPOS(char *);
142 
143 /* Convert WordNet sense number passed of IndexPtr entry to sense key. */
144 extern char *WNSnsToStr(IndexPtr, int);
145 
146 /* Search for string and/or baseform of word in database and return
147    index structure for word if found in database. */
148 extern IndexPtr GetValidIndexPointer(char *, int);
149 
150 /* Return sense number in database for word and lexsn passed. */
151 int GetWNSense(char *, char *);
152 
153 SnsIndexPtr GetSenseIndex(char *);
154 
155 char *GetOffsetForKey(unsigned int);
156 unsigned int GetKeyForOffset(char *);
157 
158 char *SetSearchdir();
159 
160 /* Return number of times sense is tagged */
161 int GetTagcnt(IndexPtr, int);
162 
163 /*
164 ** Wrapper functions for strstr that allow you to retrieve each
165 ** occurance of a word within a longer string, not just the first.
166 **
167 ** strstr_init is called with the same arguments as normal strstr,
168 ** but does not return any value.
169 **
170 ** strstr_getnext returns the position offset (not a pointer, as does
171 ** normal strstr) of the next occurance, or -1 if none remain.
172 */
173 extern void strstr_init (char *, char *);
174 extern int strstr_getnext (void);
175 
176 /*** Binary search functions (binsearch.c) ***/
177 
178 /* General purpose binary search function to search for key as first
179    item on line in open file.  Item is delimited by space. */
180 extern char *bin_search(char *, FILE *);
181 extern char *read_index(long, FILE *);
182 
183 /* Copy contents from one file to another. */
184 extern void copyfile(FILE *, FILE *);
185 
186 /* Function to replace a line in a file.  Returns the original line,
187    or NULL in case of error. */
188 extern char *replace_line(char *, char *, FILE *);
189 
190 /* Find location to insert line at in file.  If line with this
191    key is already in file, return NULL. */
192 extern char *insert_line(char *, char *, FILE *);
193 
194 #ifdef __cplusplus
195 }
196 #endif
197 
198 #endif /*_WN_*/
199 
200 
201 
202