(self,log_words, match_model=0)
return tag, cur_match
输入是list跟string都可以！

            log_words = ft_tree.getMsgFromNewSyslog(log)[1]
            匹配到返回tag，没匹配到返回0
输入是list跟string都可以！
输入是list跟string都可以！
def match(self,log_words, match_model=0):
        '''
            输入是list跟string都可以！

            log_words = ft_tree.getMsgFromNewSyslog(log)[1]
            匹配到返回tag，没匹配到返回0

        '''
        #鲁棒，输入str也是可以的
        words = []
        if type(log_words) == type(''):
             log_words = ft_tree.getMsgFromNewSyslog(log_words)[1]

        if match_model == 4:
            for word in log_words:
                words.append(word)
            #print('-------------------no sorting-----------------------')
        else:
            #sort raw log
            words_index = {}
            for word in log_words:
                    if word in self.words_frequency:
                        words_index[word] = self.words_frequency.index(word)
                    # else:
                    #     print(word,'not in the dict')
            words = [x[0] for x in sorted(words_index.items(), key=lambda x: x[1])]
            #print('-------------------after sorting-----------------------')
        #print(words)
        cur_match = []
        cur_node = self.tree.tree_list['']._head
        for word in words:
            if cur_node.find_child_node(word) != None:
                cur_node = cur_node.find_child_node(word)
                cur_match.append(word)
        cur_match = ' '.join(cur_match) #
        # print(cur_match+"\n")
        #匹配不到的话 输出0
        tag = self.template_tag_dir[cur_match] if cur_match in self.template_tag_dir else 0

        return tag, cur_match
def match ( self , log_words , match_model = 0 ) : #鲁棒，输入str也是可以的 words = [ ] if type ( log_words ) == type ( '' ) : log_words = ft_tree . getMsgFromNewSyslog ( log_words ) [ 1 ] if match_model == 4 : for word in log_words : words . append ( word ) #print('-------------------no sorting-----------------------') else : #sort raw log words_index = { } for word in log_words : if word in self . words_frequency : words_index [ word ] = self . words_frequency . index ( word ) # else: #     print(word,'not in the dict') words = [ x [ 0 ] for x in sorted ( words_index . items ( ) , key = lambda x : x [ 1 ] ) ] #print('-------------------after sorting-----------------------') #print(words) cur_match = [ ] cur_node = self . tree . tree_list [ '' ] . _head for word in words : if cur_node . find_child_node ( word ) != None : cur_node = cur_node . find_child_node ( word ) cur_match . append ( word ) cur_match = ' ' . join ( cur_match ) # # print(cur_match+"\n") #匹配不到的话 输出0 tag = self . template_tag_dir [ cur_match ] if cur_match in self . template_tag_dir else 0 return tag , cur_match