Example #1
0
def getDataWithKeyword(request):
    kw = None
    if request.method == 'GET':
        kw = request.GET['keyword']
    
    json = {}
    
    
    #熱度指數
    hi = hotIssueManager.get_heatIndex(kw) if kw not in heatIndexCache else heatIndexCache[kw]
    heatIndexCache[kw] = hi;
    
    
    hidatas = [ [u'near 30 days', u'正向', u'反向', u'全部']  ]
    
    for e in hi :
        hidatas.append(e)
    
    json['heatIndexes'] = {'title' :kw + u'議題    熱度指數',
                           'datas':hidatas                           
                           }
    
    
    #意見領袖
    ol = hotIssueManager.get_OpinionLeader(kw) if kw not in OpinionLeaderCache   else OpinionLeaderCache[kw]
    if ol is not None :
        OpinionLeaderCache[kw] = ol
    #cnt ,author_name ,title 
    authors = []
    for cnt ,author ,title ,art_id in ol :
        authors.append([cnt,author,title,art_id])
    
    json['opinionLeaders'] = {'authors':authors}
    
    #時間軸
    eles = hotIssueManager.get_TimeLine(kw) if kw not in TimeLineCache else TimeLineCache[kw]
    if eles is not None :
        TimeLineCache[kw] = eles;
    
    json['timeLine'] =[eles[0][0] , eles[0][1]]
    
    
    
    response =JsonResponse(json)
    return response
Example #2
0
def OpinionLeader(request):
    keyword = None
    if request.method == 'GET':
        keyword = request.GET['keyword']
        
    authors = []
    
    res = hotIssueManager.get_OpinionLeader(keyword) if keyword not in OpinionLeaderCache   else OpinionLeaderCache[keyword]
    if res is not None :
        OpinionLeaderCache[keyword] = res
    #cnt ,author_name ,title 
    
    for cnt ,author ,title ,art_id in res :
        authors.append([cnt,author,title,art_id])

    json = {'authors':authors}
    response =JsonResponse(json)
    return response
Example #3
0
def _getdwk(kw):
    
    json = {}
    
    
    #熱度指數
    hi = hotIssueManager.get_heatIndex(kw) if kw not in heatIndexCache else heatIndexCache[kw]
    heatIndexCache[kw] = hi;
    
    
    hidatas = [ [u'near 30 days', u'正向', u'反向', u'全部']  ]
    
    for e in hi :
        hidatas.append(e)
    
    json['heatIndexes'] = {'title' :kw + u'議題    熱度指數',
                           'datas':hidatas                           
                           }
    
    
    #意見領袖
    ol = hotIssueManager.get_OpinionLeader(kw) if kw not in OpinionLeaderCache   else OpinionLeaderCache[kw]
    if ol is not None :
        OpinionLeaderCache[kw] = ol
    #cnt ,author_name ,title 
    authors = []
    for cnt ,author ,title ,art_id in ol :
        authors.append([cnt,author,title,art_id])
    
    json['opinionLeaders'] = {'authors':authors}
    
    #時間軸
    eles = hotIssueManager.get_TimeLine(kw) if kw not in TimeLineCache else TimeLineCache[kw]
    if eles is not None :
        TimeLineCache[kw] = eles;
    
    json['timeLine'] =[eles[0][0] , eles[0][1]]
    
    return json