(self, log)
return None
match the log with template

        Args:
        --------
        log: a list of words in the log

        Returns:
        --------
        template id and variables string if match successfully, otherwise None
match the log with template
match the log with template
def match_template(self, log):
        '''match the log with template

        Args:
        --------
        log: a list of words in the log

        Returns:
        --------
        template id and variables string if match successfully, otherwise None
        '''
        log_length = len(log)
        node_candidate = self.root
        queue = [(self.root, 0)]
        while queue:
            current_node, current_index = queue[0]
            queue = queue[1:]
            if current_node.template_id:
                node_candidate = current_node
            if current_index >= log_length: continue
            for template_word in current_node.node_pool.keys():
                try:
                    next_index = log[current_index:].index(template_word)+current_index+1
                    next_node = current_node.node_pool[template_word]
                    queue.append((next_node, next_index))
                except ValueError:
                    continue

        if node_candidate.template_id:
            template_id = node_candidate.template_id
            variables = [i for i in log if i not in set(self.template_map[template_id])]
            return template_id, " ".join(variables)
        return None
def match_template ( self , log ) : log_length = len ( log ) node_candidate = self . root queue = [ ( self . root , 0 ) ] while queue : current_node , current_index = queue [ 0 ] queue = queue [ 1 : ] if current_node . template_id : node_candidate = current_node if current_index >= log_length : continue for template_word in current_node . node_pool . keys ( ) : try : next_index = log [ current_index : ] . index ( template_word ) + current_index + 1 next_node = current_node . node_pool [ template_word ] queue . append ( ( next_node , next_index ) ) except ValueError : continue if node_candidate . template_id : template_id = node_candidate . template_id variables = [ i for i in log if i not in set ( self . template_map [ template_id ] ) ] return template_id , " " . join ( variables ) return None