def getScore(file_list, play_count_list, filepath): new_file_list = {} for one_file in file_list: file = one_file.strip(".xlsx") filename = filepath + file value = {} value['playCount'] = play_count_list[file] all_comments = readComments(filename + ".xlsx") log_info = "There are " + str(len(all_comments)) + " comments in " + file print log_info.encode("gbk") if len(all_comments) == 0: continue totalScore = 0.0 writeComment(all_comments, u"./优酷/allComments/" + file + ".txt") for comment in all_comments: one_score = senScore(comment) totalScore += one_score print "The score is", totalScore / len(all_comments) value['aveScore'] = totalScore / len(all_comments) value['sum'] = len(all_comments) new_file_list[file] = value print "\n" return new_file_list
def getScore(file_list, index_path): new_file_list = {} for key, value in file_list.items(): all_comments = [] with open(index_path + value["indexFile"]) as fin: for line in fin: line_decoded = line.decode("utf-8").strip().strip(u"。").strip( ".") if len(line_decoded) > 5: all_comments.append(line_decoded) if len(all_comments) == 0: continue log_info = "There are " + str( len(all_comments)) + " comments in " + key print log_info.encode("gbk") totalScore = 0.0 writeComment(all_comments, u"./腾讯/allComments/" + key + ".txt") for comment in all_comments: one_score = senScore(comment) totalScore += one_score print "The score is", totalScore / len(all_comments) value['aveScore'] = totalScore / len(all_comments) value['sum'] = len(all_comments) new_file_list[key] = value print "\n" return new_file_list
def getScore(keyword_index): new_file_list = {} for key, value in keyword_index.items(): new_value = {} totalScore = 0.0 writeComment(value, u"./微博/allComments/" + key + ".txt") for comment in value: one_score = senScore(comment) totalScore += one_score print "The score is", totalScore / len(value) new_value['aveScore'] = totalScore / len(value) new_value['sum'] = len(value) new_file_list[key] = new_value print "\n" return new_file_list
def getScore(keyword_index): new_file_list = {} cnt = 3 for key, value in keyword_index.items(): new_value = {} totalScore = 0.0 writeComment(value, u"./百度贴吧/allComments/" + key + ".txt") for comment in value: one_score = senScore(comment) totalScore += one_score print key.encode("gbk"), "the score is", totalScore / len(value) new_value['aveScore'] = totalScore / len(value) new_value['sum'] = len(value) new_file_list[key] = new_value print "\n" cnt += 1 if cnt == 3: break return new_file_list