敏感词过滤的经典算法DFA ,做了评估实验 先上代码 [python] view plain copy #!/usr/bin/python2.6 # -*- coding: utf-8 -*- import time class Node(object): def __init__(self): self.children = None # The encode of word is UTF-8 def add_word(root,word): node = root for i in range(len(word)): if node.children == None: node.children = {} node.children[word[i]] = Node() elif word[i] not in node.children: