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.86k stars 1.51k forks source link

Raise error if no vocab entries found #157

Closed honnibal closed 4 years ago

honnibal commented 4 years ago

I passed a directory as the -vocab-file argument, which apparently doesn't trigger an error from fopen. This led to vocab_size = 0, which caused a segfault during execution.

I've raised an error if the vocab size is still 0 after trying to read the vocab file. This seems a bit better than checking for a directory, since we still should raise if an incorrect but existing file path was passed.

The PR should still be useful in addition to #138, as that PR only checks the status from fread.