def find_len(self, datas, lo_s, lo_e): t_lener = words_basic.words_base() t_messages = [] for message in self.messages: t_messages.append(message.data) t_dataone, t_datatwo, t_lens = t_lener.get_lengthinfo( t_messages, lo_s, lo_e) print(t_datatwo) print(t_lens) p_one = self.pearson(t_dataone, t_lens) p_two = self.pearson(t_datatwo, t_lens) print(p_one) print(p_two) if (p_one > 0.9 or p_two > 0.9): return 1 else: return 0
def find_lenbyaccu(self, datas, lo_s, lo_e, messages): t_lener = words_basic.words_base() t_messages = messages t_dataone, t_datatwo, t_lens = t_lener.get_lengthinfo( t_messages, lo_s, lo_e) acc_big = 0 for i in range(len(t_dataone)): if (abs((t_dataone[i] - t_lens[i])) <= 1): acc_big = acc_big + 1 acc_small = 0 for i in range(len(t_datatwo)): if (abs((t_datatwo[i] - t_lens[i])) <= 1): acc_small = acc_small + 1 if ((acc_small / len(t_dataone)) > 0.8 or (acc_big / len(t_dataone)) > 0.8): return 1 else: return 0
def find_constone(self, lo_b, lo_e,data="no"): # develop absolute or relative conster = words_basic.words_base() t_messages = [] if data == "no": for message in self.messages: t_messages.append(message.data) else: t_messages = self.messages #print(t_messages) #print(lo_b) #print(lo_e) #print(len(conster.get_logapinfo(t_messages,lo_b,lo_e))) t_r, t_l,_,_,_ = conster.get_logapinfo(t_messages,lo_b,lo_e) if (t_l[0][1] > 0.98): return 1 else: return 0
def find_constfunc(self, lo_b, lo_e,data="no"): # develop absolute or relative conster = words_basic.words_base() t_messages = [] if data == "no": for message in self.messages: t_messages.append(message.data) else: t_messages = self.messages t_r, t_l, _ = conster.get_logapinfo(t_messages, lo_b, lo_e) #t_lo = 1 - lo_b / L #t_num = 1 - len(t_r) / 255 t_en = 0 for t_pro in t_l: t_en = t_en + t_pro[1] * np.log(t_pro[1]) t_en = -t_en #print(t_l) #print(t_lo,t_num,t_en) return t_en,len(t_l)
def findserienum(self, messages, lo_s, lo_e): t_lener = words_basic.words_base() t_messages = [] for message in messages: t_messages.append(message.data) #print(len(t_messages)) t_dataone, t_datatwo, t_series = t_lener.get_seidinfo( t_messages, lo_s, lo_e) #print (len(t_dataone)) j_one = self.pearson(t_dataone, t_series) j_two = self.pearson(t_datatwo, t_series) j_final = max(j_one, j_two) if lo_s == 1: print("start") print(lo_s, lo_e) print(t_dataone) print(t_datatwo) print(t_series) return j_final
def find_lenbyaccuone(self, lo_s, lo_e, data="no", T_l=0.8): t_lener = words_basic.words_base() t_messages = [] if data == "no": for message in self.messages: t_messages.append(message.data) else: t_messages = self.messages t_dataone, t_datatwo, t_lens = t_lener.get_lengthinfo( t_messages, lo_s, lo_e) #print(t_datatwo) #print(t_lens) acc_big = 0 data_nums = {} data_smalls = {} for i in range(len(t_dataone)): diff = abs(t_dataone[i] - t_lens[i]) if diff not in data_nums: data_nums[diff] = 1 else: data_nums[diff] = data_nums[diff] + 1 acc_small = 0 for i in range(len(t_datatwo)): diff = abs(t_datatwo[i] - t_lens[i]) if diff not in data_smalls: data_smalls[diff] = 1 else: data_smalls[diff] = data_smalls[diff] + 1 #print('len:','(',lo_s,',',lo_e,')',acc_small / len(t_dataone),acc_big / len(t_dataone)) #print(acc_big) #print(acc_small) #print(len(t_dataone)) if ((acc_small / len(t_dataone)) > T_l or (acc_big / len(t_dataone)) > T_l): return 1 else: return 0
def find_lenbyaccu(self, lo_s, lo_e, data="no"): t_lener = words_basic.words_base() t_messages = [] if data == "no": for message in self.messages: t_messages.append(message.data) else: t_messages = self.messages t_dataone, t_datatwo, t_lens = t_lener.get_lengthinfo( t_messages, lo_s, lo_e) acc_big = 0 for i in range(len(t_dataone)): if (abs((t_dataone[i] - t_lens[i])) <= 1): acc_big = acc_big + 1 acc_small = 0 for i in range(len(t_datatwo)): if (abs((t_datatwo[i] - t_lens[i])) <= 1): acc_small = acc_small + 1 if ((acc_small / len(t_dataone)) > 0.8 or (acc_big / len(t_dataone)) > 0.8): return 1 else: return 0