我将如何找到文件中最常见的子字符串
序言,我正在尝试创建自己的压缩方法,其中我不在乎速度,因此大量文件上的许多迭代都是合理的。但是,我想知道是否有任何方法可以获得最常见的长度为2或更多的子字(最有可能的3个),因为任何较大的都不是合理的。我想知道您是否可以在不分开的情况下执行此操作,或者没有表格,只需搜索字符串即可。谢谢。
To preface, I am attempting to create my own compression method, wherein I do not care about speed, so lots of iterations over large files is plausible. However, I am wondering if there is any method to get the most common substrings of length of 2 or more (3 most likely), as any larger would not be plausible. I am wondering if you can do this without splitting, or anything like that, no tables, just search the string. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能想使用
collections.counter
将每个子字符串与计数相关联的内容,例如:You probably want to use something like
collections.Counter
to associate each substring with a count, e.g.: