Ejemplo n.º 1
0
 def __save_time_window_info_to_file(cls, cid, time_window_list):
     file_path = os.path.join(FileUtil.get_zscore_dir(), str(cid) + "-time-window-info.txt")
     with codecs.open(file_path, "wb", "utf-8") as output_file:
         for time_window in time_window_list:
             time_window_info = unicode(str(time_window.time_window_index)) + u"\t" \
                                + DateTimeUtil.format_barrage_play_timestamp(time_window.start_timestamp) + u"\t" \
                                + DateTimeUtil.format_barrage_play_timestamp(time_window.end_timestamp) + u"\t" \
                                + unicode(str(time_window.barrage_count)) + u"\t" \
                                + unicode(str(time_window.valid_barrage_word_count)) + u"\n"
             output_file.write(time_window_info)
Ejemplo n.º 2
0
 def __save_high_emotion_clips_to_file(self, high_emotion_clips, global_zscore_threshold,
                                       left_zscore_threshold, right_zscore_threshould):
     file_path = os.path.join(FileUtil.get_zscore_dir(), self.cid + "-high-emotion-clips.txt")
     with codecs.open(file_path, "wb", "utf-8") as output_file:
         output_file.write(unicode(str(global_zscore_threshold)) + u"\t" +
                           unicode(str(left_zscore_threshold)) + u"\t" +
                           unicode(str(right_zscore_threshould)) + u"\n")
         for emotion_clip in high_emotion_clips:
             str_info = u""
             for item in emotion_clip:
                 str_info += (unicode(str(item)) + u"\t")
             str_info = str_info[0: len(str_info) - 1] + u"\n"
             output_file.write(str_info)
Ejemplo n.º 3
0
 def __save_high_emotion_clips_to_file(self, high_emotion_clips,
                                       global_zscore_threshold,
                                       left_zscore_threshold,
                                       right_zscore_threshould):
     file_path = os.path.join(FileUtil.get_zscore_dir(),
                              self.cid + "-high-emotion-clips.txt")
     with codecs.open(file_path, "wb", "utf-8") as output_file:
         output_file.write(
             unicode(str(global_zscore_threshold)) + u"\t" +
             unicode(str(left_zscore_threshold)) + u"\t" +
             unicode(str(right_zscore_threshould)) + u"\n")
         for emotion_clip in high_emotion_clips:
             str_info = u""
             for item in emotion_clip:
                 str_info += (unicode(str(item)) + u"\t")
             str_info = str_info[0:len(str_info) - 1] + u"\n"
             output_file.write(str_info)
Ejemplo n.º 4
0
 def load_high_emotion_clips_from_file(cls, cid):
     file_path = os.path.join(FileUtil.get_zscore_dir(), cid + "-high-emotion-clips-lda.txt")
     first_line_flag = True
     high_emotion_clips = []
     global_zscore_threshold = 0
     left_zscore_threshold = 0
     right_zscore_threshould = 0
     with codecs.open(file_path, "rb", "utf-8") as input_file:
         for line in input_file:
             split_info = line.strip().split("\t")
             if first_line_flag:
                 first_line_flag = False
                 global_zscore_threshold = split_info[0]
                 left_zscore_threshold = split_info[1]
                 right_zscore_threshould = split_info[2]
                 continue
             high_emotion_clips.append(split_info)
     return high_emotion_clips, global_zscore_threshold, left_zscore_threshold, right_zscore_threshould
Ejemplo n.º 5
0
 def load_high_emotion_clips_from_file(cls, cid):
     file_path = os.path.join(FileUtil.get_zscore_dir(),
                              cid + "-high-emotion-clips-lda.txt")
     first_line_flag = True
     high_emotion_clips = []
     global_zscore_threshold = 0
     left_zscore_threshold = 0
     right_zscore_threshould = 0
     with codecs.open(file_path, "rb", "utf-8") as input_file:
         for line in input_file:
             split_info = line.strip().split("\t")
             if first_line_flag:
                 first_line_flag = False
                 global_zscore_threshold = split_info[0]
                 left_zscore_threshold = split_info[1]
                 right_zscore_threshould = split_info[2]
                 continue
             high_emotion_clips.append(split_info)
     return high_emotion_clips, global_zscore_threshold, left_zscore_threshold, right_zscore_threshould
Ejemplo n.º 6
0
        left_zscore_threshold = 0
        right_zscore_threshould = 0
        with codecs.open(file_path, "rb", "utf-8") as input_file:
            for line in input_file:
                split_info = line.strip().split("\t")
                if first_line_flag:
                    first_line_flag = False
                    global_zscore_threshold = split_info[0]
                    left_zscore_threshold = split_info[1]
                    right_zscore_threshould = split_info[2]
                    continue
                high_emotion_clips.append(split_info)
        return high_emotion_clips, global_zscore_threshold, left_zscore_threshold, right_zscore_threshould


if __name__ == "__main__":
    zscore = Zscore(
        "2171229",
        os.path.join(FileUtil.get_zscore_dir(), "hd-zscore-result-lda.txt"),
        30, 10, 4)
    # zscore.gen_sorted_zscore_file(threshold_value=5)
    # # zscore.gen_possible_high_emotion_clips()
    high_emotion_clips = zscore.gen_possible_high_emotion_clips()
    for emotion_clip in high_emotion_clips:
        str_info = u""
        for item in emotion_clip:
            str_info += (unicode(str(item)) + u"\t")
        str_info = str_info[0:len(str_info) - 1]
        str_info += u"\n"
        print str_info
Ejemplo n.º 7
0
        first_line_flag = True
        high_emotion_clips = []
        global_zscore_threshold = 0
        left_zscore_threshold = 0
        right_zscore_threshould = 0
        with codecs.open(file_path, "rb", "utf-8") as input_file:
            for line in input_file:
                split_info = line.strip().split("\t")
                if first_line_flag:
                    first_line_flag = False
                    global_zscore_threshold = split_info[0]
                    left_zscore_threshold = split_info[1]
                    right_zscore_threshould = split_info[2]
                    continue
                high_emotion_clips.append(split_info)
        return high_emotion_clips, global_zscore_threshold, left_zscore_threshold, right_zscore_threshould


if __name__ == "__main__":
    zscore = Zscore("2171229", os.path.join(FileUtil.get_zscore_dir(), "hd-zscore-result-lda.txt"), 30, 10, 4)
    # zscore.gen_sorted_zscore_file(threshold_value=5)
    # # zscore.gen_possible_high_emotion_clips()
    high_emotion_clips = zscore.gen_possible_high_emotion_clips()
    for emotion_clip in high_emotion_clips:
        str_info = u""
        for item in emotion_clip:
            str_info += (unicode(str(item)) + u"\t")
        str_info = str_info[0: len(str_info) - 1]
        str_info += u"\n"
        print str_info