Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function RabinKarpSet(string s[1~K], string patterns[1~N])
- //用hash table or Cuckoo Filter 來儲存敏感詞彙相關資料
- set hsSet := emptySet
- //前置處理
- foreach p in patterns
- insert hash(p[1~M]) into hsSet
- hs := hash(s[1~M])
- //匹配運算
- for i from 1 to K-M+1
- if hs ∈ hsSet and s[i~i+M-1] ∈ patterns
- return i
- hs := hash(s[i+1..i+M])
- return not found
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement