修正关键词对编号的映射模式

This commit is contained in:
lzjqsdd 2016-05-03 00:40:35 -05:00
parent 92e20e0957
commit 69dfb7b4b1

View File

@ -90,7 +90,7 @@ class InverseIndex:
indexdoc = dict() indexdoc = dict()
f = open(Global.inverse_dir+'id.txt','wb') f = open(Global.inverse_dir+'id.txt','wb')
for name in vectorizer.get_feature_names(): for name in vectorizer.get_feature_names():
indexdoc[i] = name indexdoc[name] = i
i+=1 i+=1
f.write(json.dumps(indexdoc)) f.write(json.dumps(indexdoc))
f.close() f.close()
@ -99,7 +99,7 @@ class InverseIndex:
row = tfidf.shape[0] row = tfidf.shape[0]
for i in range(0,colnum): for i in range(0,colnum):
filename = Global.inverse_dir+str(i/Global.filesize)+'.txt' filename = Global.inverse_dir+str(i/Global.filesize)+'.txt'
f = open(filename,'a') f = open(filename,'a'
idx_list = dict() idx_list = dict()
for j in range(0,row): for j in range(0,row):
val = tfidf[j,i] val = tfidf[j,i]