while i < number_of_pairs:
#count+=1
#print("count: ",count)
#print(i)
if chunk * int(number_of_pairs/2) + i > data_len:
break
# chunk *125+i >443000
#print("id :",chunk*int(number_of_pairs)/2+i)
p = true_pairs_id[chunk * int(number_of_pairs/2) + i]
#print(chunk*int(number_of_pairs/2)+int(i/2))
#print("p: ",len(p))
#print("p: ",p)
q0 = cur.execute("SELECT " + self.feature_type + " FROM " + self.feature_type + " WHERE id=?", (p[0],))
if self.feature_type == 'acfg':
adj0, node0, lenghts0 = self.get_data_from_acfg(json_graph.adjacency_graph(json.loads(q0.fetchone()[0])))
elif self.feature_type == 'lstm_cfg':
adj0, node0, lenghts0 = self.get_data_from_cfg(json_graph.adjacency_graph(json.loads(q0.fetchone()[0])))
q1 = cur.execute("SELECT " + self.feature_type + " FROM " + self.feature_type + " WHERE id=?", (p[1],))
#print("p1: ",len(p1))
if self.feature_type == 'acfg':
adj1, node1, lenghts1 = self.get_data_from_acfg(json_graph.adjacency_graph(json.loads(q0.fetchone()[0])))
elif self.feature_type == 'lstm_cfg':
adj1, node1, lenghts1 = self.get_data_from_cfg(json_graph.adjacency_graph(json.loads(q1.fetchone()[0])))
pairs.append(((adj0, node0), (adj1, node1)))
lenghts.append([lenghts0, lenghts1])
labels.append(+1)
p = false_pairs_id[chunk * int(number_of_pairs/2) +i]
#print("p false: ",len(p))
q0 = cur.execute("SELECT " + self.feature_type + " FROM " + self.feature_type + " WHERE id=?", (p[0],))
if self.feature_type == 'acfg':
adj0, node0,lenghts0 = self.get_data_from_acfg(json_graph.adjacency_graph(json.loads(q0.fetchone()[0])))
elif self.feature_type == 'lstm_cfg':
adj0, node0, lenghts0 = self.get_data_from_cfg(json_graph.adjacency_graph(json.loads(q0.fetchone()[0])))
q1 = cur.execute("SELECT " + self.feature_type + " FROM " + self.feature_type + " WHERE id=?", (p[1],))
if self.feature_type == 'acfg':
adj1, node1, lenghts1 = self.get_data_from_acfg(json_graph.adjacency_graph(json.loads(q0.fetchone()[0])))
elif self.feature_type == 'lstm_cfg':
adj1, node1, lenghts1 = self.get_data_from_cfg(json_graph.adjacency_graph(json.loads(q1.fetchone()[0])))
pairs.append(((adj0, node0), (adj1, node1)))
lenghts.append([lenghts0, lenghts1])
labels.append(-1)
i += 2
If i increases by 2 each time, should i be divided by 2 in the following code, otherwise it will skip one.
p = true_pairs_id[chunk * int(number_of_pairs/2) + i]
TO
p = true_pairs_id[chunk * int(number_of_pairs/2) + int(i/2)]