def NewsContext(requests,art_id): article = hotIssueManager.get_articles_by_id(art_id, with_pushtxt = True) content =u''.join([ item.context for item in article.pushtxts]) wds = wdlib.get_wordcloud_Tags(content) articles = mdl.get_Article_top1000_in_a_week() base_art_index = _get_index_by_artId(articles,art_id) #關聯新聞 related_news = hotGroup.get_related_news(articles, base_art_index)[0:5] ls = mdl.get_News_top10_in_a_week() crntIdx = _get_index_by_artId(ls,art_id) rg = range(0,10); if crntIdx in rg : rg.remove( crntIdx ) randIndex = random.sample(rg, 5) randIndex.sort() # hotIssues = [ ls[i] for i in randIndex ] return render_to_response('Issue.html',locals()) pass
import MySQLdb import codecs,re from string import Template from pytagcloud import * from operator import itemgetter from WordCutLibs import wordCloudlib as wc import uniout word_collect="" pushcontent_All="" sentence = '' with codecs.open(u'E:/ptt/[Title][問卦] 被告要多久才收得到傳票[Author]l90lT (陸軍1901梯)[Date]Thu Aug 6 21-45-09 2015.txt','r','utf-8') as f : sentence = f.read() wc.get_wordcloud_Tags(sentence, 0, 20, 1, 1) words = jieba.cut(sentence, cut_all=False) #print "Output 精确模式 Full Mode:" wdic = {} for w in words : if re.match('\s|XD{1,}|\.{1,}|…',w) : continue if wdic.get(w) is None : wdic[w] = 1 else : wdic[w] += 1 swd = sorted(wdic.iteritems(), key=itemgetter(1), reverse=True)
import thread wordCloudlib.get_wordcloud_Tags(u""" 作者Ipanema (blue)看板Gossiping標題[新聞] 八仙塵爆案第7死 萬能科大林芷妘不治時間Thu Jul 16 15:51:29 2015 1.媒體來源: 蘋果即時 2.完整新聞標題: 八仙塵爆案第7死 萬能科大林芷妘不治 3.完整新聞內文: 2015年07月16日15:44 憾!八仙塵爆案第7死!就讀萬能科大的林芷妘(19歲),全身有百分之81的深二度到三 度灼傷,灼傷範圍包括顏面、四肢及軀幹,且併發吸入性肺灼傷,在6月28日轉到衛福部 桃園醫院治療,因呼吸困難故緊急插管治療。 7月2日因呼吸衰竭接受葉克膜治療,狀況逐漸改善;7月7日脫離葉克膜,並進行多次傷口 清創。7月15日因感染導致敗血症,併發多重器官衰竭,再度接受葉克膜治療,經醫療團 隊與家屬討論後,家人不忍讓她再受苦痛,16日下午3時30分移除葉克膜拔管。(突發中 心/桃園報導) 4.完整新聞連結 (或短網址): http://www.appledaily.com.tw/realtimenews/article/local/20150716/649283/ 5.備註: """,st= 0,end = 50) #res = mysqlLinker.callproc('Get_Top','20150731','20150805',300)