def tfidf(t, d, D): return ntf(t, d) * idf(t, D)
W = dict() # IDFS = dict() D_ = sorted(D.keys()) # print D print ["TERM"] + [d for d in D_] for term in W_: # W[term] = dict() temp = [term] # IDFS[term] = idf(term, D) for di in D_: if not di in inmutfable[term]: temp.append(0) else: t = inmutfable[term][di] temp.append(ntf(t, di, W=inmutfable, D=D) * idf(term, D)) print temp # for di in inmutfable[term]: # t = inmutfable[term][di] # print inmutfable[term][di] # W[term][di] = ntf(t, di, W=inmutfable, D=D) * idf(term, D) # matrixtfidf = [["TERM"] + [d for d in D_]] ## print ["TERM"] + [d for d in D_] # for t in W_: # temp = [w] # for di in D_: # if not di in W[w]: # temp.append(0) # continue