inpho / vsm

Vector Space Model Framework developed for InPhO
http://inpho.github.io/vsm
Other
36 stars 14 forks source link

dist_word_doc multiple word error #126

Closed colinallen closed 8 years ago

colinallen commented 8 years ago
tf_v.dist_word_doc(['biology','cell'])
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-9-6f1f62210f83> in <module>()
----> 1 tf_v.dist_word_doc(['biology','cell'])

/Users/colin/anaconda/lib/python2.7/site-packages/vsm-0.4.0a8-py2.7-macosx-10.5-x86_64.egg/vsm/viewer/tfviewer.pyc in dist_word_doc(self, word_or_words, weights, label_fn, filter_nan, print_len, as_strings, dist_fn, order)
    194                                filter_nan=filter_nan,
    195                                print_len=print_len, as_strings=as_strings,
--> 196                                dist_fn=dist_fn, order=order)
    197 
    198 

/Users/colin/anaconda/lib/python2.7/site-packages/vsm-0.4.0a8-py2.7-macosx-10.5-x86_64.egg/vsm/viewer/wrappers.pyc in dist_word_doc(word_or_words, corp, context_type, mat, weights, filter_nan, print_len, label_fn, as_strings, dist_fn, order)
    215     doc = np.zeros((mat.shape[0],1), dtype=np.float)
    216     if len(weights) == 0:
--> 217         doc[words,:] = np.ones(len(words))
    218     else:
    219         doc[words,:] = weights

ValueError: shape mismatch: value array of shape (2,) could not be broadcast to indexing result of shape (2,1)