def processLine(sogouObserverStr): cols = sogouObserverStr.split(',') sogouObserver = SogouObserver('') for col in cols: #print col attrval = col.split("=") #print len(attrval) if(len(attrval)<2): continue #print len(attrval) #print attrval setattr(sogouObserver, attrval[0], attrval[1]) sogouObserver.phonetype = CommonUtil.getPhonetype(sogouObserver.h) #print 'h:',sogouObserver.h #print 'ks:',sogouObserver.ks #print sogouObserver.phonetype return sogouObserver
def statPhonetypeuser(userStatisticsMap): phonetypeuserTopNumber =20 phonetypeuserStatisticsMap = {} for uid in userStatisticsMap.keys(): phonetype = CommonUtil.getPhonetype(uid) if(len(phonetype)==0): continue if (phonetypeuserStatisticsMap.has_key(phonetype)==False): phonetypeuserStatisticsMap[phonetype] = PhonetypeuserStatistics() phonetypeuserStatisticsMap[phonetype].phonetype=phonetype updatePhonetypeuserStatistics(phonetypeuserStatisticsMap[phonetype],userStatisticsMap[uid]) print 'phonetype user sort by click number' sortByClick = sorted(phonetypeuserStatisticsMap.values(), key=operator.attrgetter('click'),reverse=True)[0:phonetypeuserTopNumber] for pts in sortByClick: pts.toString() print 'phonetype user sort by close number' sortByClose = sorted(phonetypeuserStatisticsMap.values(), key=operator.attrgetter('close'),reverse=True)[0:phonetypeuserTopNumber] for pts in sortByClose: pts.toString()