def GET(self):
data=web.input()
if data:
ID=data.id
news = dict()
title, content, url=id_index.get_data(int(ID))
news['content'] = content.decode("utf-8")
news['title'] = title.decode("utf-8")
news['url'] = url.decode("utf-8")
recomand=[]
#????
cut = jieba.cut_for_search(content)
word_list = []
for word in cut:
if word not in punct and word not in Letters_and_numbers:
# ????????????????????
if recommand.stopword.has_key(word.encode("utf-8")):
pass
else:
word_list.append(word.encode("utf-8"))
topk= recommand.calculate(word_list, config.recommand_numbers, 10)
for i in topk:#????
#for i in recommand.dic[int(ID)]:#????
if i !=int(ID):
title, content, url=id_index.get_data(i)
recomand.append([title.decode('utf-8'),content.decode('utf-8'),url.decode('utf-8')])
news['recommand']=recomand
del title,content,url,recomand
else:
ID=''
news = dict()
news['title'] = "No Such News"
news['content'] = "Oh No!"
news['url'] = "#"
news['recommand']=[['','',''] for m in range(config.recommand_numbers)]
return render.news(news)
评论列表
文章目录