[go: up one dir, main page]

Menu

[4c9db1]: / src / wni.h  Maximize  Restore  History

Download this file

243 lines (189 with data), 6.9 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
/* wni.h
* Artha - Free cross-platform open thesaurus
* Copyright (c) 2009 Sundaram Ramaswamy, legends2k@yahoo.com
*
* Artha is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Artha is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Artha; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* WordNet Interface Header
* This header exposes the functions required to query data from wordnet
*/
#ifndef __WNI_H__
#define __WNI_H__
#include <glib.h>
#ifdef WNI_INDEPENDENT_DEBUG
#define DEBUG_LEVEL 3
#endif
G_BEGIN_DECLS
#if defined(HAVE_CONFIG_H) || defined(WNI_INDEPENDENT_DEBUG)
# if DEBUG_LEVEL >= 1
# define G_DEBUG(...) g_debug(__VA_ARGS__)
# endif /* DEBUG_LEVEL >= 1 */
# if DEBUG_LEVEL >= 2
# define G_MESSAGE(...) g_message(__VA_ARGS__)
# endif /* DEBUG_LEVEL >= 2 */
# if DEBUG_LEVEL >= 3
# include <glib/gprintf.h>
# define G_PRINTF(...) g_printf(__VA_ARGS__)
# endif /* DEBUG_LEVEL >= 3 */
#endif /* HAVE_CONFIG_H */
#ifndef __noop
#define __noop(...) ((void) 0)
#endif
#ifndef G_DEBUG
#define G_DEBUG __noop
#endif
#ifndef G_MESSAGE
#define G_MESSAGE __noop
#endif
#ifndef G_PRINTF
#define G_PRINTF __noop
#endif
/* For adjectives, indicates synset type */
#define DONT_KNOW 0
#define DIRECT_ANT 1 /* direct antonyms (cluster head) */
#define INDIRECT_ANT 2 /* indrect antonyms (similar) */
#define PERTAINYM 3 /* no antonyms or similars (pertainyms) */
#define MAX_BUFFER 256
#define SYNONYM_MAPPING 1
#define ANTONYM_MAPPING 2
#define PROPERTY_MAPPING 3
/* index.sense reveals that the longest lemma in WordNet is
* blood-oxygenation_level_dependent_functional_magnetic_resonance_imaging
* 71 chars long; this needs to be updated when WordNet lib. is updated
* although it's very hard to beat this one ;) last updated for WN 3.1
*/
#define MAX_LEMMA_LEN 75
#define MAX_SENSE_DIGITS 5
// WNI Data Structures Used
typedef enum
{
WORDNET_INTERFACE_NONE = 0,
WORDNET_INTERFACE_OVERVIEW = 1 << 0,
WORDNET_INTERFACE_ANTONYMS = 1 << 1,
WORDNET_INTERFACE_DERIVATIONS = 1 << 2,
WORDNET_INTERFACE_PERTAINYMS = 1 << 3,
WORDNET_INTERFACE_ATTRIBUTES = 1 << 4,
WORDNET_INTERFACE_SIMILAR = 1 << 5,
WORDNET_INTERFACE_CLASS = 1 << 6,
WORDNET_INTERFACE_CAUSES = 1 << 7,
WORDNET_INTERFACE_ENTAILS = 1 << 8,
WORDNET_INTERFACE_HYPERNYMS = 1 << 9,
WORDNET_INTERFACE_HYPONYMS = 1 << 10,
WORDNET_INTERFACE_HOLONYMS = 1 << 11,
WORDNET_INTERFACE_MERONYMS = 1 << 12,
WORDNET_INTERFACE_ALL =(WORDNET_INTERFACE_OVERVIEW | WORDNET_INTERFACE_ANTONYMS | WORDNET_INTERFACE_DERIVATIONS |
WORDNET_INTERFACE_PERTAINYMS | WORDNET_INTERFACE_ATTRIBUTES | WORDNET_INTERFACE_SIMILAR |
WORDNET_INTERFACE_CLASS | WORDNET_INTERFACE_CAUSES | WORDNET_INTERFACE_ENTAILS |
WORDNET_INTERFACE_HYPERNYMS | WORDNET_INTERFACE_HYPONYMS | WORDNET_INTERFACE_HOLONYMS | WORDNET_INTERFACE_MERONYMS)
} WNIRequestFlags;
struct _nym
{
WNIRequestFlags id; // type of the node
gpointer data; // data based on the type
};
typedef struct _nym WNINym;
struct _overview
{
GSList *definitions_list; // list of WNIDefinitionItems
GSList *synonyms_list; // list of WNIPropertyItems
};
typedef struct _overview WNIOverview;
struct _definition_item
{
gchar *lemma; // searched term to which these definitions correspond to
guint8 id; // unique ID for this node within definitions_list of it's parent
guint8 pos; // part of speech
guint8 count; // count of WNIDefinitions present
GSList *definitions; // list of WNIDefinitions
};
typedef struct _definition_item WNIDefinitionItem;
struct _definition
{
gchar *definition; // definition string
guint16 tag_count; // number of semantic tags to sense; refer WN
GSList *examples; // list of example strings
};
typedef struct _definition WNIDefinition;
// each synonym belongs to a POS and inside a POS it maps to a particular sense
// sense numbers starts from 0, for each POS category
struct _synonym_mapping
{
guint8 id; // POS it belongs to can be found by comparing against WNIDefinitionItem.id
guint16 sense; // nth sense inside a particular POS
};
typedef struct _synonym_mapping WNISynonymMapping;
struct _antonym_item
{
gchar *term; // antonym term
guint16 sense; // WordNet sense number - 1
guint8 relation; // direct of indirect antonym flag DIRECT_ANT/INDIRECT_ANT
GSList *mapping; // list of WNIAntonymMappings
GSList *implications; // list of WNIImplications
};
typedef struct _antonym_item WNIAntonymItem;
struct _implication
{
gchar *term; // relative term
guint16 sense; // WordNet sense number - 1
};
typedef struct _implication WNIImplication;
struct _antonym_mapping
{
guint8 id; // POS it belongs to can be found by comparing against WNIDefinitionItem.id
guint16 sense; // nth sense inside a particular POS
guint8 related_word_count; // number of related words
};
typedef struct _antonym_mapping WNIAntonymMapping;
struct _properties_list
{
GSList *properties_list; // list of WNIPropertyItems
};
typedef struct _properties_list WNIProperties;
struct _property_item
{
gchar *term; // relative term
GSList *mapping; // list of WNIPropertyMappings or WNISynonymMappings
};
typedef struct _property_item WNIPropertyItem;
struct _property_mapping
{
guint16 self_sense; // WordNet sense id - 1
guint8 id; // POS it belongs to can be found by comparing against WNIDefinitionItem.id
guint16 sense; // nth sense inside a particular POS
};
typedef struct _property_mapping WNIPropertyMapping;
struct _class_item
{
gchar *term; // relative term based on classification
guint8 self_pos; // POS of this term
guint16 self_sense; // WordNet sense id - 1
guint8 id; // mapping to which WNIDefinitionItem it belongs to
guint16 sense; // nth sense inside a particular POS
guint8 type; // type of the classification -> [ISMEMBERPTR ... HASPARTPTR] (refer wn.h)
};
typedef struct _class_item WNIClassItem;
struct _tree_list
{
GSList *word_list; // list of WNIImplications
guint8 type; // type of the implications -> [1 ... MAXPTR] (refer wn.h)
};
typedef struct _tree_list WNITreeList;
// WNI ~ Exposed functions
gboolean wni_request_nyms(gchar *search_str, GSList **response_list, WNIRequestFlags additional_request_flags, gboolean advanced_mode);
void wni_free(GSList **response_list);
int wni_strcmp0(const char *s1, const char *s2);
G_END_DECLS
#endif /* __WNI_H__ */