汉字字符串查找算法
Python 代码可用于普通字符串搜索算法,例如 Boyer-Moore。我希望在中文字符上使用它,但似乎相同的实现不起作用。为了使该算法适用于汉字,我该怎么做?我指的是:
http://en.literateprograms.org/Boyer-Moore_string_search_algorithm_ (Python)#参考文献
There is Python code available for normal string searching algorithms, such as Boyer-Moore. I am looking to use this on Chinese characters, but it doesn't seem like the same implementation would work. What would I do in order to make the algorithm work with Chinese characters? I am referring to this:
http://en.literateprograms.org/Boyer-Moore_string_search_algorithm_(Python)#References
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只要你的所有文本都是 unicode 格式,它就应该可以正常工作。该算法看起来与序列无关,前提是每个“元素”的长度都是一个序列单元。
As long as all your text is in unicodes it should work just fine. The algorithm looks sequence-independent, provided each "element" is one sequence-unit in length.