Algorithm aho-corasick算法的状态转移表

Algorithm aho-corasick算法的状态转移表,algorithm,pattern-matching,aho-corasick,Algorithm,Pattern Matching,Aho Corasick,请帮助我理解Aho Corasick算法中多个模式的状态转换表的构造 请给我一个简单而详细的解释,以便我能理解 我在看这篇论文,这是我的动画 谢谢。第一阶段 创建关键字树: Starting at the root, follow the path labeled by chars of Pi If the path ends before Pi, continue it by adding new edges and ...

请帮助我理解Aho Corasick算法中多个模式的状态转换表的构造

请给我一个简单而详细的解释,以便我能理解

我在看这篇论文,这是我的动画

谢谢。

第一阶段 创建关键字树

Starting at the root, follow the path labeled by chars of Pi If the path ends before Pi, continue it by adding new edges and ... nodes for the remaining characters of P Store identifier i of Pi at the terminal node of the path
gives the set of patterns recognized when entering state q
正如您在上面的伪代码中看到的,它调用两个函数:fail(q)和output(q)

失败(q)://对于q=0给出了在不匹配位置输入的状态

failure(q) is the node labeled by the longest proper suffix  w of L(q) ...
    s.t. w is a prefix of some pattern
//L(q) is the label of node q as the concatenation of edge labels ...
   on the path from the root to q
输出(q)

Starting at the root, follow the path labeled by chars of Pi If the path ends before Pi, continue it by adding new edges and ... nodes for the remaining characters of P Store identifier i of Pi at the terminal node of the path
gives the set of patterns recognized when entering state q
计算这两个函数后,自动机如下所示:

现在,您可能想知道何时计算这些方法,因此请查看这些更正式的形式:


希望这能有所帮助,如果仍然有不明确的地方,请毫不犹豫地询问。

那么,您的问题到底在哪里?到目前为止,你从算法中得到了什么?你的问题是在预处理阶段还是失效函数?它在表的构造过程中处于预处理阶段。如何用值填充表格并关联下一个状态???您会发现下载和研究原始论文非常有用:。这篇论文写得很好,很平易近人。不过,你必须把它读几遍,然后认真思考。但是状态表的构造已经解释得很清楚了。请你再详细说明一下:下一周我们将把关键字树扩展成一个自动机,以支持线性时间匹配。我认为这是关键部分。@Hynek Pichi Vychodil:是的,我正在与MS Paint合作:)谢谢你回答我的问题,这很有用。但是你能解释一下如何填充状态转换表吗?我们将根据它在搜索时遍历trie。@Shail_42:看,这个算法可以分为两个阶段:1-创建关键字树2-创建自动机。因此,在第一阶段中确实没有状态转换,但它只是两个节点之间的一条边,不过您可以将此树显示为一个表。我编辑了答案,请重新检查。