aboutsummaryrefslogtreecommitdiff
path: root/textproc/wordnet/files/patch-official
blob: 1701ab0ccb2a3aa394f05b5996cb017def7b1ab0 (plain) (blame)
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
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