Exemplo n.º 1
0
def getTimeLine(request):
    kw = None
    if request.method == 'GET':
        kw = request.GET['keyword']
    
    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
Exemplo n.º 2
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
Exemplo n.º 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