def get_threads(self, verbose=False): """Get threads.""" if self.threads is not None: return self.threads df = self.data threads = list() visited = dict() total = df.shape[0] c = 0 for i in df.iterrows(): if verbose: c += 1 if c % 1000 == 0: print "Processed %d of %d" %(c,total) if(i[1]['In-Reply-To'] is None): root = Node(i[0], i[1]) visited[i[0]] = root threads.append(Thread(root)) elif(i[1]['In-Reply-To'] not in visited.keys()): root = Node(i[1]['In-Reply-To']) succ = Node(i[0],i[1], root) root.add_successor(succ) visited[i[1]['In-Reply-To']] = root visited[i[0]] = succ threads.append(Thread(root, known_root=False)) else: parent = visited[i[1]['In-Reply-To']] node = Node(i[0],i[1], parent) parent.add_successor(node) visited[i[0]] = node self.threads = threads return threads
def get_threads(self, verbose=False): """Get threads.""" if self.threads is not None: return self.threads df = self.data threads = list() visited = dict() total = df.shape[0] c = 0 for i in df.iterrows(): if verbose: c += 1 if c % 1000 == 0: print("Processed %d of %d" %(c,total)) if(i[1]['In-Reply-To'] == 'None'): root = Node(i[0], i[1]) visited[i[0]] = root threads.append(Thread(root)) elif(i[1]['In-Reply-To'] not in list(visited.keys())): root = Node(i[1]['In-Reply-To']) succ = Node(i[0],i[1], root) root.add_successor(succ) visited[i[1]['In-Reply-To']] = root visited[i[0]] = succ threads.append(Thread(root, known_root=False)) else: parent = visited[i[1]['In-Reply-To']] node = Node(i[0],i[1], parent) parent.add_successor(node) visited[i[0]] = node self.threads = threads return threads