Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
651 B
2
Indexable
Never
def Map2(r, dir_name):
    key, values = r[0], r[1]

    this_vector = defaultdict(float)

    
    with open("%s/v%d.txt" % (dir_name, key)) as sub_vector:
    	print("vector file number: ", key)
    	for line in sub_vector:
            pom = [float(x) for x in line.split(",")]
            print("line in vector with above key: ", pom)
            this_vector[pom[0]] = pom[1]
            
    #print(this_vector)
    results = []

    for el in values:
    	result = this_vector[el[0]] * el[2]
    	print("matrix: ", el, "vector: ", this_vector[el[0]], "result: ",result)
    	
    	
    	results.append([el[0], result])
        
    return results