Beispiel #1
0
 def load_set_user(cls):
     res = set()
     file = join(Config.folderData, Config.folderDataParsed, Config.folderExp, Config.fileUserSet)
     fileFriend = join(Config.folderData, Config.folderDataParsed, Config.folderExp, Config.fileSocialGraph)
     res1 = FileTool.ReadFileColumnSet(file)
     res2 = FileTool.ReadFileColumnSet(fileFriend)
     res = res2
     return res
Beispiel #2
0
    def get_exp_ratio_user_set(self):
        #self.setUser = LoadData.load_set_alluser(self.flagExp, False)
        self.setUser = LoadData.load_set_user()
        self.setCheckUser = LoadData.load_set_checkuser(self.flagExp)
        #user list
        self.userList = list(self.setUser)
        if (Config.flag_exp_only_check_user):
            self.userList = list(self.setCheckUser)
        maxUserCnt = Config.maxUserCnt
        self.userList = ProcessTool.get_list_str_sub_n(self.userList,
                                                       maxUserCnt)
        self.userSet = ProcessTool.list_to_set(self.userList)

        (self.userKnowHomeList,
         self.userNotKnowHomeList) = ProcessTool.splitListByRatio(
             self.userList, Config.r_user_hasHomeLocation)

        print "userList:", len(self.userList)
        print "userKnowHomeList:", len(self.userKnowHomeList)
        print "userNotKnowHomeList:", len(self.userNotKnowHomeList)
        #(self.userHasCheckinList, self.userNotHasCheckinList) = ProcessTool.splitListByRatio(self.userList, Config.r_user_hasCheckin)

        #write file
        fileUser = join(Config.folderData, Config.folderDataParsed,
                        Config.folderExp, Config.folderRatio,
                        Config.fileUserSet)
        FileTool.WriteStrListToFileWithNewLine(self.userList, fileUser)

        fileUserKnowHome = join(Config.folderData, Config.folderDataParsed,
                                Config.folderExp, Config.folderRatio,
                                Config.fileKnowHome + Config.fileUserSet)
        fileUserNotKnowHome = join(
            Config.folderData, Config.folderDataParsed, Config.folderExp,
            Config.folderRatio,
            Config.fileNot + Config.fileKnowHome + Config.fileUserSet)
        FileTool.WriteStrListToFileWithNewLine(self.userKnowHomeList,
                                               fileUserKnowHome)
        FileTool.WriteStrListToFileWithNewLine(self.userNotKnowHomeList,
                                               fileUserNotKnowHome)

        fileUserHasCheckin = join(Config.folderData, Config.folderDataParsed,
                                  Config.folderExp, Config.folderRatio,
                                  Config.fileHasCheckin + Config.fileUserSet)
        fileUserNotHasCheckin = join(
            Config.folderData, Config.folderDataParsed, Config.folderExp,
            Config.folderRatio,
            Config.fileNot + Config.fileHasCheckin + Config.fileUserSet)
Beispiel #3
0
    def load_set_alluser(cls, flagExp=True, flagRatio = True):
        res = []
        if(flagExp):
            file = join(Config.folderData, Config.folderDataParsed, Config.folderExp, Config.fileUserSet)
            if(flagRatio == True):
                file = join(Config.folderData, Config.folderDataParsed, Config.folderExp, Config.folderRatio, Config.fileUserSet)
            res = FileTool.ReadFileColumnSet(file)

        return res
Beispiel #4
0
 def load_dict_user_city(cls, flagExp = True, flagRatio=True):
     InOut.console_func_begin("load_dict_user_city")
     dictUserCity = {}
     if(flagExp):
         file = join(Config.folderData, Config.folderDataParsed, Config.folderExp, Config.fileUserCity)
         if(flagRatio):
             file = join(Config.folderData, Config.folderDataParsed, Config.folderExp, Config.folderRatio, Config.fileUserCity)
         dictUserCity = FileTool.ReadFileDictStrStr(file, 0, 1)
     return dictUserCity
Beispiel #5
0
    def get_exp_ratio_user(self):
        InOut.console_func_begin("get_exp_ratio_user")
        fileSrc = join(Config.folderData, Config.folderDataParsed,
                       Config.folderExp, Config.fileUser)
        fileDst = join(Config.folderData, Config.folderDataParsed,
                       Config.folderExp, Config.folderRatio, Config.fileUser)

        colIndex = 0
        FileTool.FiltFileByColInSet(fileSrc, fileDst, colIndex, self.userSet)
Beispiel #6
0
 def get_exp_ratio_social(self):
     InOut.console_func_begin("get_exp_ratio_social")
     fileExpSocial = join(Config.folderData, Config.folderDataParsed,
                          Config.folderExp, Config.fileSocialGraph)
     fileDstSocial = join(Config.folderData, Config.folderDataParsed,
                          Config.folderExp, Config.folderRatio,
                          Config.fileSocialGraph)
     #FileTool.FiltFileByTwoColAtleastOneInSet(fileExpSocial, fileDstSocial, 0, 1, self.userSet)
     FileTool.FiltFileByTwoColAllInSet(fileExpSocial, fileDstSocial, 0, 1,
                                       self.userSet)
Beispiel #7
0
 def loadDictEdgeFromFile(cls, file, flagAsc=False):
     dict = {}
     listLineList = FileTool.ReadListLineListFromFile(file)
     for listLine in listLineList:
         if (flagAsc == False):
             edge = Edge.read_edge_from_list(listLine)
         else:
             edge = Edge.read_edge_asc_from_list(listLine)
         if (edge == None):
             continue
         ProcessTool.dictStrSetstr_add_str_str(dict, edge.start, edge.end)
     return dict
Beispiel #8
0
    def loadDictUserFromFile(cls, file=""):
        InOut.console_func_begin("User loadDictUserFromFile")

        listLineList = FileTool.ReadListLineListFromFile(file)

        dict = {}
        for listLine in listLineList:
            user = User.read_user_from_list(listLine)
            if (user == None):
                continue
            dict[user.id] = user
        return dict
Beispiel #9
0
    def get_exp_ratio_rating(self):
        InOut.console_func_begin("get_exp_ratio_rating")
        print "userSet:", len(self.userSet)

        fileExp = join(Config.folderData, Config.folderDataParsed,
                       Config.folderExp, Config.fileRating)
        fileDst = join(Config.folderData, Config.folderDataParsed,
                       Config.folderExp, Config.folderRatio, Config.fileRating)

        colIndex = 0
        FileTool.FiltFileByColInSet(fileExp, fileDst, colIndex, self.userSet)
        pass
Beispiel #10
0
    def get_exp_ratio_checkin(self):
        InOut.console_func_begin("get_exp_ratio_checkin")
        print "userSet:", len(self.userSet)
        fileSrc = join(Config.folderData, Config.folderDataParsed,
                       Config.folderExp, Config.fileCheckin)
        fileDst = join(Config.folderData, Config.folderDataParsed,
                       Config.folderExp, Config.folderRatio,
                       Config.fileCheckin)
        colIndex = 1
        FileTool.FiltFileByColInSet(fileSrc, fileDst, colIndex, self.userSet)

        pass
Beispiel #11
0
    def get_exp_ratio_venue(self):
        InOut.console_func_begin("get_exp_ratio_venue")

        setVenue = self.get_exp_ratio_venue_set()
        fileExpVenue = join(Config.folderData, Config.folderDataParsed,
                            Config.folderExp, Config.fileVenue)
        fileExpVenueCity = join(Config.folderData, Config.folderDataParsed,
                                Config.folderExp, Config.fileVenueCity)

        fileDstVenue = join(Config.folderData, Config.folderDataParsed,
                            Config.folderExp, Config.folderRatio,
                            Config.fileVenue)
        fileDstVenueCity = join(Config.folderData, Config.folderDataParsed,
                                Config.folderExp, Config.folderRatio,
                                Config.fileVenueCity)

        #FileTool.CopyFile(fileExpVenue, fileDstVenue)
        #FileTool.CopyFile(fileExpVenueCity, fileDstVenueCity)

        FileTool.FiltFileByColInSet(fileExpVenue, fileDstVenue, 0, setVenue)
        FileTool.FiltFileByColInSet(fileExpVenueCity, fileDstVenueCity, 0,
                                    setVenue)

        pass
Beispiel #12
0
 def load_set_checkuser(cls, flagExp = True):
     res = []
     if(flagExp):
         file = join(Config.folderData, Config.folderDataParsed, Config.folderExp,  Config.fileFlagCheck + Config.fileUserSet)
         res = FileTool.ReadFileColumnSet(file)
     return res
Beispiel #13
0
 def load_set_userHasCheckin(cls):
     file = join(Config.folderData, Config.folderDataParsed, Config.folderExp, Config.folderRatio, Config.fileHasCheckin + Config.fileUserSet)
     res = FileTool.ReadFileColumnSet(file)
     return res
Beispiel #14
0
 def load_set_userNotKnowHome(cls):
     file = join(Config.folderData, Config.folderDataParsed, Config.folderExp, Config.folderRatio, Config.fileNot + Config.fileKnowHome + Config.fileUserSet)
     res = FileTool.ReadFileColumnSet(file)
     return res
Beispiel #15
0
 def get_exp_ratio_rating_venue_set(self):
     fileDst = join(Config.folderData, Config.folderDataParsed,
                    Config.folderExp, Config.folderRatio, Config.fileRating)
     res = FileTool.ReadFileColumnSet(fileDst, '\t', 1)
     return res