stanfordnlp / GloVe

Software in C and data files for the popular GloVe model for distributed word representations, a.k.a. word vectors or embeddings
Apache License 2.0
6.81k stars 1.51k forks source link

there may be a bug in cooccur.c when the bin file is empty #218

Open cicido opened 1 year ago

cicido commented 1 year ago

in file cooccur.c line 177-184 for (i = 0; i < num; i++) { sprintf(filename,"%s_%04d.bin",file_head,i); fid[i] = fopen(filename,"rb"); if (fid[i] == NULL) {log_file_loading_error("file", filename); free_fid(fid, num); free(pq); return 1;} fread(&new, sizeof(CREC), 1, fid[i]); new.id = i; insert(pq,new,i+1); } when the content in "filename" is empty, the CREC new will computer twice。 let's see the corpus has only the following words: "training the vectors can be speeded up by increasing the training parallelism to match the number of physical CPU cores available" there will generate two bin files, and one of files is empty.

AngledLuffa commented 1 year ago

 when the content in "filename" is empty, the CREC new will computer twice。

Please clarify what you mean by this.  sizeof(CREC) will be the size of the C object, not the data file itself.

In terms of git usage, it will be easier to follow newly posted issues if you:

asdf {
  stuff;
}

https://github.com/stanfordnlp/GloVe/blob/a6f2b947358bd5a0bdb825af3ebe429ab43a3cb5/src/common.h#L7