This patch mostly contains the differences between the search.c as in the released version 1.6 vs. the later version found in ftp://ftp.cogsci.princeton.edu/pub/wordnet/bugfixes/ I also modified the groupexc function to fix the problem documented in ftp://ftp.cogsci.princeton.edu/pub/wordnet/README.bugs (buf[8] vs. buf[9] -- point 5 at the bottom) and modified it to avoid allocating 1Kb from the stack and needlessly strcpy the argument given. Nothing gets written into the string anyway, and we can examine it without making a duplicate copy. -mi --- src/lib/search.c Fri Nov 7 11:27:45 1997 +++ src/lib/search.c Fri Aug 7 12:57:08 1998 @@ -19,3 +19,3 @@ -static char *Id = "$Id: search.c,v 1.134 1997/11/07 16:27:36 wn Exp $"; +static char *Id = "$Id: search.c,v 1.136 1998/08/07 17:51:32 wn Exp $"; @@ -448,2 +448,7 @@ + /* Can't do earlier - calls indexlookup which messes up strtok calls */ + + for (i = 0; i < synptr->wcount; i++) + synptr->wnsns[i] = getsearchsense(synptr, i + 1); + return(synptr); @@ -588,3 +593,3 @@ sprintf(tbuf, " (Sense %d)\n", - getsearchsense(cursyn, synptr->pto[i])); + cursyn->wnsns[synptr->pto[i] - 1]); printsynset(prefix, cursyn, tbuf, DEFOFF, synptr->pto[i], @@ -1405,16 +1405,15 @@ static int groupexc(unsigned long off1, unsigned long off2) { - char buf[8], *p, linebuf[1024]; + char buf[9], *p, *line; sprintf(buf, "%8.8lu", (off1 < off2 ? off1 : off2)); if ((p = bin_search(buf, cousinexcfp)) != NULL) { sprintf(buf, "%8.8lu", (off2 > off1 ? off2 : off1)); - strcpy(linebuf, p + 9); /* don't copy key */ - linebuf[strlen(linebuf) - 1] = '\0'; /* strip off newline */ - p = strtok(linebuf, " "); - while (p && strcmp(p, buf)) + line = p + 9; /* ignore the key */ + p = strtok(line, " "); + while (p && strncmp(p, buf, 8)) p = strtok(NULL, " "); } return(p ? 1 : 0); @@ -1775,2 +1780,8 @@ wnresults.numforms++; + + if (ptrtyp == COORDS) { /* clean up by removing hypernym */ + lastsyn = synlist->ptrlist; + synlist->ptrlist = lastsyn->ptrlist; + free_synset(lastsyn); + } } @@ -1781,3 +1792,3 @@ /* Recursive search algorithm to trace a pointer tree and return results - in linked list of data structures. */ + in linked list of data structures. */ @@ -1785,4 +1796,5 @@ { - int i; + int i, j; SynsetPtr cursyn, synlist = NULL, lastsyn = NULL; + int tstptrtyp, docoords; @@ -1805,5 +1817,13 @@ } - + + if (ptrtyp == COORDS) { + tstptrtyp = HYPERPTR; + docoords = 1; + } else { + tstptrtyp = ptrtyp; + docoords = 0; + } + for (i = 0; i < synptr->ptrcount; i++) { - if((synptr->ptrtyp[i] == ptrtyp) && + if((synptr->ptrtyp[i] == tstptrtyp) && ((synptr->pfrm[i] == 0) || @@ -1814,5 +1834,2 @@ - for (i = 0; i < cursyn->wcount; i++) - cursyn->wnsns[i] = getsearchsense(cursyn, i + 1); - if (lastsyn) @@ -1828,3 +1845,5 @@ (depth+1)); - } + } else if (docoords) { + cursyn->ptrlist = traceptrs_ds(cursyn, HYPOPTR, NOUN, 0); + } } @@ -2193,3 +2212,3 @@ if (wnsnsflag) - sprintf(buf + strlen(buf), "#%d", getsearchsense(synptr, wdnum + 1)); + sprintf(buf + strlen(buf), "#%d", synptr->wnsns[wdnum]); @@ -2246,3 +2265,3 @@ sprintf(tbuf + strlen(tbuf), "#%d", - getsearchsense(psynptr, wdoff + 1)); + psynptr->wnsns[wdoff]); if (!first) @@ -2333,2 +2352,9 @@ $Log: search.c,v $ + * Revision 1.136 1998/08/07 17:51:32 wn + * added COORDS to traceptrs_ds and findtheinfo_ds + * fixed getsearchsense code to only happen in parse_synset + * + * Revision 1.135 1998/08/07 13:04:24 wn + * *** empty log message *** + * * Revision 1.134 1997/11/07 16:27:36 wn