コード例 #1
0
ファイル: generate_S_R.py プロジェクト: PeterWanng/hfs
def createGml(gid, workfolder_real, workfolder_real_gml, addcommentlist=False):
    wb2g = weibo2graph()
    weibofilep = workfolder_real + gt.findfiles(
        workfolder_real, '*' + str(gid) + '*' + '.repost')[0]
    gmlfilep = workfolder_real_gml + str(gid) + '.gml'
    g = wb2g.start(weibofilep,
                   gmlfilep,
                   timep=None,
                   addcommentlist=addcommentlist)
    return g
コード例 #2
0
 def get_graph(self,
               weibofilep,
               gmlfilep=None,
               timep=None,
               addcommentlist=True):
     from weibo_tools import weibo2graph
     wb2g = weibo2graph()
     g = wb2g.start(weibofilep,
                    gmlfilep,
                    timep=timep,
                    addcommentlist=addcommentlist)
     return g
コード例 #3
0
def getdata_one(weibofp):
    from weibo_tools import weibo2graph
    from weibo_tools import wbg
    wb2g = weibo2graph()

    wbfilep_fw = r'G:\HFS\WeiboData\HFSWeibo\test\toy.repost'
    wbfilep_cm = None
    txtlist = wb2g.getxtlist_old(wbfilep, wbfilep_comt)
    txtlist = wb2g.transoldweibo2new(txtlist)
    searchmid = os.path.basename(wbfilep).split('.')[0]
    firstline = wb2g.findmetacoc(searchmid=searchmid)
    if firstline == -1:
        pass
    else:
        txtlist.insert(0, firstline)

    res = []
    for wb in txtlist:

        wb4g = wbg(line, oldweibo)
        res.append(wb4g.reposts_count)
コード例 #4
0
#encoding=utf8
'the main frame of mobilization model'
'basic model-training-model-simulating real case-comparing SR'
import sys
sys.path.append('../..')
from tools import commontools as gtf
from tools import graphtools
from weibo_tools import weibo2graph
import random
import os
import numpy as np
gt = gtf()
weibo2g = weibo2graph()
grt = graphtools()
print 'hello'
from cmo_regression import regression_cmo
import igraph as ig


def selecTime(timelist, periodcnt):
    timelistPeriodNow = []
    lenyt = len(timelist) / float(periodcnt)
    #print len(timelist)
    for j in range(1, periodcnt + 1):
        i = int(round(j * lenyt))
        i = i if i > 1 else 1
        i = i if i < len(timelist) else len(timelist) - 1
        if len(timelist) < 1:
            timelistPeriodNow.append('0')
        else:
            timelistPeriodNow.append(timelist[i])