bmschmidt/wordVectors

Fallback to read.binary.vectors if read.vectors fails

bmschmidt opened this issue · 1 comments

One problem with the switch to writing in the binary format is that users who upgrade (which is basically forced with every R version bump) may have code that gets broken if they use the suffix '.vectors'. (They can still read in an old model; but now if they train a new one with the old suffix, it chokes on read.)

One easy way to solve this would be to try-catch the read.vectors function: if it fails to read something as text, we could just give a short at reading it in binary format. If the results are plausible (how to test? Simply by length, probably; or else valid unicode-ness of the row names), return them.

Taking an easier route here: just writing a warning if you try to write.binary a filename that ends in ".vectors" a1a0b66