散列正克用循环多项式 - java实现 [英] Hashing n-grams by cyclic polynomials - java implementation

查看:284
本文介绍了散列正克用循环多项式 - java实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我解决了一些问题,涉及拉宾,卡普字符串搜索算法。该算法需要滚动哈希要快那么天真的搜索。 这篇文章介绍如何实现滚动哈希值。我实现了拉宾,卡普滚动哈希没有问题,发现几个实现实施,而且文中还提到了计算的复杂性和散列正克用循环多项式为prefered。它链接到<一个href="https://www.se.auckland.ac.nz/courses/SOFTENG250/archive/2006/assignments/Hashing/BuzHash.java"相对=nofollow> BuzHash 实现这样的技术,但我不知道如何可以用来构建正克散在它的上面。我想有一些像这个

I'm solving some problem that involves Rabin–Karp string search algorithm. This algorithm requires rolling hash to be faster then naive search. This article describes how to implement rolling hash. I implemented "Rabin-Karp rolling hash" without problems and found few implementations implementations, but article also mentions computational complexity and that hashing n-grams by cyclic polynomials is prefered. It links to BuzHash implementation of such technique but I wonder how it can be used to build n-gram hash on top of it. I want to have something like this or

CPHash cp = new CPHash("efghijk");
cp.shiftRight('l') // now we got hash of "fghijki"
cp.shiftLeft('d') // "defghi"

有关Java的。

有关的人谁都会遇到字符串搜索(像我)有一些文章,我发现有用的相关的问题:的 1 2 3

For people who will encounter problems related with string search (like me) there are some articles that I found usefull: 1, 2, 3

推荐答案

我最近发表的一个Apache许可的,它实现几个滚动散列功能,包括循环和拉宾,卡普Java库:

I recently published an Apache licensed Java library which implements several rolling hash functions including Cyclic and Rabin-Karp:

HTTP://$c$c.google.com/p/rollinghashjava/

https://github.com/lemire/rollinghashjava

这篇关于散列正克用循环多项式 - java实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆