我有一个列表( & gt; 50,000 单词) 。 列表中的每个单词都有一套相关的别名。 每个单词平均有五个别名 。
我得到一个输入字符串 平均为 6 个单词。 我必须做到 :
// Pseudocode
foreach word in input_string
if word == x or word in alias(x) // x is a word in the list
tag (word, x) // Tag word with x
else
tag (word, 0)
end
有哪些快速数据结构可以维持一个化名清单,以便能迅速执行上面提到的化名?