假设我们有一个关键字字典
Dictionary A: {A1, A2, A3}假设我们有第二个关键词字典(与第一个不同)
Dictionary B: {B1, B2, B3, B4}我想从输入文本中的两个字典中找到序列中无序的关键字对的所有可能匹配(即,仅用空格分隔)。例如,将以下内容作为输入文本
We are not looking for single words from either dictionary on their own, like
A2 or B4, nor are we looking for sequences of words from only one dictionary,
like A1 A3 or B4 B2. We are looking for tuples of words from both dictionaries
in a sequence together, like B1 A3 and A2 B4 and B4 A2.Aho算法是一种传统的方法,它通过构造一个类似trie的自动机并逐个字符扫描文本,从输入文本中的单一字典中高效地找到所有匹配。
对于多字典,是否有一种有效的方法来扩展Aho-Corasick?
发布于 2016-04-10 09:35:08
是的,您可以为每个文档构建一个普通的aho-corasick自动机和一个个人:Using Aho-Corasick, can strings be added after the initial tree is built?。
https://stackoverflow.com/questions/36319219
复制相似问题