pycl/Code/VectorSpace.py
def makeVectorSpace():
	"""Generate the vector space from dictionary data."""
	global words, wordlist, documents, docnames, eliminated

	wordlist = words.keys()
	docnames = documents.keys()

	# eliminate words that appear in all documents
	for x in wordlist:
		if len(words.get(x, [])) == len(docnames):
			eliminated.append(x)
			del words[x]
	wordlist = words.keys()

	# create vectors
	vectorspace = []
	for x in docnames:
		vector = len(wordlist) * [ 0 ]
		for i in range(len(wordlist)):
			vector[i] = documents[x].get(wordlist[i], 0)

		# append vector with relative frequencies
		#i = float(vsum(vector))
		#vectorspace.append(tuple([ float(a)/i for a in vector ]))
		vectorspace.append(tuple(vector))

	# convert vectorspace to tuple
	return tuple(vectorspace)
Generate the vector space from dictionary data.
Generate the vector space from dictionary data.
Generate the vector space from dictionary data .
def makeVectorSpace():
	global words, wordlist, documents, docnames, eliminated
	wordlist = words.keys()
	docnames = documents.keys()
	for x in wordlist:
		if len(words.get(x, [])) == len(docnames):
			eliminated.append(x)
			del words[x]
	wordlist = words.keys()
	vectorspace = []
	for x in docnames:
		vector = len(wordlist) * [ 0 ]
		for i in range(len(wordlist)):
			vector[i] = documents[x].get(wordlist[i], 0)
		vectorspace.append(tuple(vector))
	return tuple(vectorspace)
def makeVectorSpace ( ) : global words , wordlist , documents , docnames , eliminated wordlist = words . keys ( ) docnames = documents . keys ( ) for x in wordlist : if len ( words . get ( x , [ ] ) ) == len ( docnames ) : eliminated . append ( x ) del words [ x ] wordlist = words . keys ( ) vectorspace = [ ] for x in docnames : vector = len ( wordlist ) * [ 0 ] for i in range ( len ( wordlist ) ) : vector [ i ] = documents [ x ] . get ( wordlist [ i ] , 0 ) vectorspace . append ( tuple ( vector ) ) return tuple ( vectorspace )
Generate the vector space from dictionary data.
Generate the vector space from dictionary data .
"""Generate the vector space from dictionary data.""" # eliminate words that appear in all documents # create vectors # append vector with relative frequencies #i = float(vsum(vector)) #vectorspace.append(tuple([ float(a)/i for a in vector ])) # convert vectorspace to tuple