|
|
|
|
|
|
|
|
|
|
|
#ifdef _WINDOWS |
|
#include <windows.h> |
|
#endif |
|
|
|
#include <stdio.h> |
|
#include <stdlib.h> |
|
#include <string.h> |
|
#define USE_INTERP_RESULT 1 |
|
#include <tcl.h> |
|
#include <tk.h> |
|
#include <wn.h> |
|
|
|
static char *Id = "$Id: stubs.c,v 1.7 2005/04/29 19:01:57 wn Exp $"; |
|
|
|
static char resultbuf[SEARCHBUF]; |
|
|
|
#ifndef HAVE_LANGINFO_CODESET |
|
|
|
char *nl_langinfo(int item) { |
|
|
|
static char val[4] = "Sun"; |
|
return(val); |
|
} |
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int wn_findvalidsearches (ClientData clientData, Tcl_Interp *interp, |
|
int argc, char *argv[]) { |
|
unsigned int bitfield; |
|
static char bitfieldstr[32]; |
|
char *morph; |
|
int pos; |
|
if (argc != 3) { |
|
interp -> result = |
|
"usage: findvalidsearches searchword partofspeechnum"; |
|
return TCL_ERROR; |
|
} |
|
pos = atoi (argv[2]); |
|
bitfield = is_defined (argv[1], pos); |
|
if ((morph = morphstr (argv[1], pos)) != NULL) { |
|
do { |
|
bitfield |= is_defined (morph, pos); |
|
} while ((morph = morphstr (NULL, pos)) != NULL); |
|
} |
|
sprintf (bitfieldstr, "%u", bitfield); |
|
interp -> result = bitfieldstr; |
|
return TCL_OK; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int wn_bit (ClientData clientData, Tcl_Interp *interp, |
|
int argc, char *argv[]) { |
|
unsigned int bitfield; |
|
static char bitfieldstr[32]; |
|
int whichbit; |
|
if (argc != 2) { |
|
interp -> result = "usage: bit bitnum"; |
|
return TCL_ERROR; |
|
} |
|
whichbit = atoi (argv[1]); |
|
bitfield = bit (whichbit); |
|
sprintf (bitfieldstr, "%u", bitfield); |
|
interp -> result = bitfieldstr; |
|
return TCL_OK; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
int wn_search (ClientData clientData, Tcl_Interp *interp, |
|
int argc, char *argv[]) { |
|
int pos, searchtype, sense; |
|
char *morph; |
|
if (argc != 5) { |
|
interp -> result = |
|
"usage: search searchword partofspeechnum searchtypenum sensenum"; |
|
return TCL_ERROR; |
|
} |
|
pos = atoi (argv[2]); |
|
searchtype = atoi (argv[3]); |
|
sense = atoi (argv[4]); |
|
strcpy (resultbuf, findtheinfo (argv[1], pos, searchtype, sense)); |
|
if ((morph = morphstr (argv[1], pos)) != NULL) { |
|
do { |
|
strcat (resultbuf, findtheinfo (morph, pos, searchtype, sense)); |
|
} while ((morph = morphstr (NULL, pos)) != NULL); |
|
} |
|
interp -> result = resultbuf; |
|
return TCL_OK; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
int wn_glosses (ClientData clientData, Tcl_Interp *interp, |
|
int argc, char *argv[]) { |
|
if (argc != 2) { |
|
interp -> result = "usage: glosses [1 | 0]"; |
|
return TCL_ERROR; |
|
} |
|
dflag = atoi (argv[1]); |
|
return TCL_OK; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
int wn_fileinfo (ClientData clientData, Tcl_Interp *interp, |
|
int argc, char *argv[]) { |
|
if (argc != 2) { |
|
interp -> result = "usage: fileinfo [1 | 0]"; |
|
return TCL_ERROR; |
|
} |
|
fileinfoflag = atoi (argv[1]); |
|
return TCL_OK; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
int wn_byteoffset (ClientData clientData, Tcl_Interp *interp, |
|
int argc, char *argv[]) { |
|
if (argc != 2) { |
|
interp -> result = "usage: byteoffset [1 | 0]"; |
|
return TCL_ERROR; |
|
} |
|
offsetflag = atoi (argv[1]); |
|
return TCL_OK; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
int wn_senseflag (ClientData clientData, Tcl_Interp *interp, |
|
int argc, char *argv[]) { |
|
if (argc != 2) { |
|
interp -> result = "usage: senseflag [1 | 0]"; |
|
return TCL_ERROR; |
|
} |
|
wnsnsflag = atoi (argv[1]); |
|
return TCL_OK; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
int wn_contextualhelp (ClientData clientData, Tcl_Interp *interp, |
|
int argc, char *argv[]) { |
|
int pos, searchtype; |
|
if (argc != 3) { |
|
interp -> result = "usage: contextualhelp partofspeechnum searchtypenum"; |
|
return TCL_ERROR; |
|
} |
|
pos = atoi (argv[1]); |
|
searchtype = atoi (argv[2]); |
|
interp -> result = helptext[pos][searchtype]; |
|
return TCL_OK; |
|
} |
|
|
|
|
|
|
|
|
|
int wn_reopendb (ClientData clientData, Tcl_Interp *interp, |
|
int argc, char *argv[]) { |
|
if (argc != 1) { |
|
interp -> result = "usage: reopendb"; |
|
return TCL_ERROR; |
|
} |
|
re_wninit (); |
|
return TCL_OK; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
int wn_abortsearch (ClientData clientData, Tcl_Interp *interp, |
|
int argc, char *argv[]) { |
|
if (argc != 1) { |
|
interp -> result = "usage: abortsearch"; |
|
return TCL_ERROR; |
|
} |
|
abortsearch = 1; |
|
return TCL_OK; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
void tkwn_doevents (void) { |
|
while (Tcl_DoOneEvent (TCL_WINDOW_EVENTS | TCL_DONT_WAIT) != 0) {} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
int tkwn_displayerror (char *msg) { |
|
#ifdef _WINDOWS |
|
MessageBeep (MB_ICONEXCLAMATION); |
|
MessageBox (NULL, msg, "WordNet Library Error", |
|
MB_ICONEXCLAMATION | MB_OK | MB_TASKMODAL | MB_SETFOREGROUND); |
|
#else |
|
fprintf (stderr, "%s", msg); |
|
#endif |
|
return -1; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
int Wordnet_Init (Tcl_Interp *interp) { |
|
interface_doevents_func = tkwn_doevents; |
|
display_message = tkwn_displayerror; |
|
wninit (); |
|
Tcl_CreateCommand (interp, "findvalidsearches", (void *) |
|
wn_findvalidsearches, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); |
|
Tcl_CreateCommand (interp, "bit", (void *) wn_bit, (ClientData) NULL, |
|
(Tcl_CmdDeleteProc *) NULL); |
|
Tcl_CreateCommand (interp, "search", (void *) wn_search, (ClientData) |
|
NULL, (Tcl_CmdDeleteProc *) NULL); |
|
Tcl_CreateCommand (interp, "glosses", (void *) wn_glosses, (ClientData) |
|
NULL, (Tcl_CmdDeleteProc *) NULL); |
|
Tcl_CreateCommand (interp, "fileinfo", (void *) wn_fileinfo, (ClientData) |
|
NULL, (Tcl_CmdDeleteProc *) NULL); |
|
Tcl_CreateCommand (interp, "byteoffset", (void *) wn_byteoffset, |
|
(ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); |
|
Tcl_CreateCommand (interp, "senseflag", (void *) wn_senseflag, |
|
(ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); |
|
Tcl_CreateCommand (interp, "contextualhelp", (void *) wn_contextualhelp, |
|
(ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); |
|
Tcl_CreateCommand (interp, "reopendb", (void *) wn_reopendb, (ClientData) |
|
NULL, (Tcl_CmdDeleteProc *) NULL); |
|
Tcl_CreateCommand (interp, "abortsearch", (void *) wn_abortsearch, |
|
(ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); |
|
return TCL_OK; |
|
} |
|
|
|
|