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 heatIndex(request):
    kw = None
    if request.method == 'GET':
        kw = request.GET['keyword']
    
    eles = hotIssueManager.get_heatIndex(kw) if kw not in heatIndexCache else heatIndexCache[kw]
    heatIndexCache[kw] = eles;
    json = {}
    
    json['datas'] = ([ [u'near 30 days', u'正向', u'反向', u'全部']  ])
    
    for e in eles :
        json['datas'].append(e)
    
    json['title'] = kw + u'議題    熱度指數'
    
    
    
    response =JsonResponse(json)
    return response
    pass
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