我需要将一系列用户输入的单词与一个大的单词词典相匹配(以确保输入的值存在).
因此,如果用户输入:
"orange" it should match an entry "orange' in the dictionary.
Run Code Online (Sandbox Code Playgroud)
现在的问题是用户还可以输入通配符或一系列通配符,比如说
"or__ge" which would also match "orange"
Run Code Online (Sandbox Code Playgroud)
关键要求是:
* this should be as fast as possible.
* use the smallest amount of memory to achieve it.
Run Code Online (Sandbox Code Playgroud)
如果单词列表的大小很小,我可以使用包含所有单词的字符串并使用正则表达式.
但是,鉴于单词列表可能包含数十万个企业,我认为这不会起作用.
那么某种"树"是这样的方式......?
对此有任何想法或建议将完全赞赏!
先谢谢,马特