Esempio n. 1
0
	def add_vectors(self, a=[], b=[], log_tf_a = True, log_tf_b = True):
		if not b:
			b = SuperList()
			b.do_padding(new_len=a.__len__(), padding_data=0)
		elif a.__len__() != b.__len__():
			if self.verbose: print "add_vectors:", a.__len__(), "!=", b.__len__()
			raise Exception
		sum_vector = SuperList()
		for i in range(0,a.__len__()):
			sum_vector.append(self.log_tf(a[i], do_nothing = not log_tf_a) + self.log_tf(b[i], do_nothing = not log_tf_b))
		return sum_vector
Esempio n. 2
0
	def _non_zero_indices(self, l):
		ret = SuperList()
		for i in range(0,len(l)):
			if l[i] != 0: ret.append(i)
		return ret
Esempio n. 3
0
	def divide_vector(self, vector=[], scalar=1):
		result = SuperList()
		for item in vector:
			result.append(float(item)/scalar)
		return result
Esempio n. 4
0
	def vector_log_tf(self, a=[], do_nothing=False):
		new_vector = SuperList()
		for i in range(0,a.__len__()):
			new_vector.append(self.log_tf(value=a[i], do_nothing=do_nothing))
		return new_vector