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
|
static std::list<Sense> WNOverview(char *searchstr, int pos)
{
SynsetPtr cursyn;
IndexPtr idx = NULL;
char *cpstring = searchstr, *bufstart;
int sense, i, offsetcnt;
int svdflag, skipit;
unsigned long offsets[MAXSENSE];
std::list<Sense> synsets;
cpstring = searchstr;
bufstart = searchbuffer;
for (i = 0; i < MAXSENSE; i++)
offsets[i] = 0;
offsetcnt = 0;
int TaggedNo=0;
while ((idx = getindex(cpstring, pos)) != NULL) {
cpstring = NULL; /* clear for next call to getindex() */
wnresults.SenseCount[wnresults.numforms++] = idx->off_cnt;
wnresults.OutSenseCount[wnresults.numforms] = 0;
printbuffer(" \n");
/* Print synset for each sense. If requested, precede
synset with synset offset and/or lexical file information.*/
std::string sense_str;
std::string eg_use;
for (sense = 0; sense < idx->off_cnt; sense++) {
for (i = 0, skipit = 0; i < offsetcnt && !skipit; i++)
if (offsets[i] == idx->offset[sense])
skipit = 1;
if (!skipit) {
offsets[offsetcnt++] = idx->offset[sense];
cursyn = read_synset(pos, idx->offset[sense], idx->wd);
sense_str="";
eg_use="";
sense_str=cursyn->defn;
char *char_array;
char_array=(char *)malloc(sizeof(sense_str.c_str()+1));
strcpy(char_array, sense_str.c_str());
char *sense_char;
char *egUse_char;
if(cursyn->defn)
{
sense_char=strtok(char_array,"\"");
egUse_char=strtok(NULL,"\"");
sense_str=sense_char;
if(egUse_char!=NULL)
eg_use=egUse_char;
else eg_use="";
}
else
{
strcpy(sense_char,"");
strcpy(egUse_char,"");
sense_str=sense_char;
eg_use=egUse_char;
}
Sense word_sense;
// THIS IS WHERE EXCEPTION OCCURS, and if this code is placed before while or in another procedure, it works
word_sense.SetNodeLabel(sense_str);
word_sense.SetExampleUseString(eg_use);
//change: insert a synset in the list
synsets.push_back(word_sense);
free_synset(cursyn);
}
}
wnresults.numforms++;
free_index(idx);
}
return synsets;
}
|