commonsense team mailing list archive
-
commonsense team
-
Mailing list archive
-
Message #00098
[Bug 439070] [NEW] tf-idf views don't support slicing
Public bug reported:
It fails rather dramatically:
/home/kcarnold/code/divisi/csc/divisi/normalized_view.pyc in __getitem__(self, indices)
263 else:
264 term, document = indices
--> 265 return self.tf(term, document) * self.idf(term)
266
267
/home/kcarnold/code/divisi/csc/divisi/normalized_view.pyc in tf(self, term, document)
253 else:
254 term_count = self.tensor[term, document]
--> 255 return term_count / self.counts_for_document[document]
256
257 def idf(self, term):
/home/kcarnold/code/divisi/csc/divisi/tensor.pyc in __div__(self, other)
327 you might be able to make it divide by some other kind of object.
328 """
--> 329 return self * (1.0/other)
330
331 def __idiv__(self, other):
/home/kcarnold/code/divisi/csc/divisi/tensor.pyc in __mul__(self, other)
272 return self.cmul(other)
273 else:
--> 274 return self.dot(other)
275
276 def __rmul__(self, other):
/home/kcarnold/code/divisi/csc/divisi/tensor.pyc in dot(self, other, mode, into, reverse)
969 def dot(self, other, mode=0, into=None, reverse=False):
970 if max(self.ndim, other.ndim) == 1:
--> 971 return self._vectordot(other, reverse=reverse)
972 if max(self.ndim, other.ndim) == 2:
973 return self._2ddot(other, reverse=reverse)
/home/kcarnold/code/divisi/csc/divisi/tensor.pyc in _vectordot(self, other, reverse)
995 raise IndexError("Incompatible dimensions for sparse vectordot (%r._vectordot(%r)" % (self, other))
996 if not isinstance(other, DictTensor):
--> 997 other = other.to_sparse()
998 if len(other) < len(self):
999 other, self = self, other
AttributeError: 'numpy.ndarray' object has no attribute 'to_sparse'
** Affects: divisi
Importance: Undecided
Status: New
--
tf-idf views don't support slicing
https://bugs.launchpad.net/bugs/439070
You received this bug notification because you are a member of
Commonsense Computing, which is the registrant for Divisi.
Status in Divisi: New
Bug description:
It fails rather dramatically:
/home/kcarnold/code/divisi/csc/divisi/normalized_view.pyc in __getitem__(self, indices)
263 else:
264 term, document = indices
--> 265 return self.tf(term, document) * self.idf(term)
266
267
/home/kcarnold/code/divisi/csc/divisi/normalized_view.pyc in tf(self, term, document)
253 else:
254 term_count = self.tensor[term, document]
--> 255 return term_count / self.counts_for_document[document]
256
257 def idf(self, term):
/home/kcarnold/code/divisi/csc/divisi/tensor.pyc in __div__(self, other)
327 you might be able to make it divide by some other kind of object.
328 """
--> 329 return self * (1.0/other)
330
331 def __idiv__(self, other):
/home/kcarnold/code/divisi/csc/divisi/tensor.pyc in __mul__(self, other)
272 return self.cmul(other)
273 else:
--> 274 return self.dot(other)
275
276 def __rmul__(self, other):
/home/kcarnold/code/divisi/csc/divisi/tensor.pyc in dot(self, other, mode, into, reverse)
969 def dot(self, other, mode=0, into=None, reverse=False):
970 if max(self.ndim, other.ndim) == 1:
--> 971 return self._vectordot(other, reverse=reverse)
972 if max(self.ndim, other.ndim) == 2:
973 return self._2ddot(other, reverse=reverse)
/home/kcarnold/code/divisi/csc/divisi/tensor.pyc in _vectordot(self, other, reverse)
995 raise IndexError("Incompatible dimensions for sparse vectordot (%r._vectordot(%r)" % (self, other))
996 if not isinstance(other, DictTensor):
--> 997 other = other.to_sparse()
998 if len(other) < len(self):
999 other, self = self, other
AttributeError: 'numpy.ndarray' object has no attribute 'to_sparse'
Follow ups
References