fjs-string-matching icon indicating copy to clipboard operation
fjs-string-matching copied to clipboard

How can I make your fjs program suppor "?" searching?

Open zzfeed opened this issue 5 years ago • 2 comments

such as finding pattern "a?baa" in text "aabaabaaba bab aaabaa", ? stands for any alphabet,thanks

zzfeed avatar Oct 14 '20 16:10 zzfeed

It is fairly easy to extend the delta array (BMS part) to support indeterminate letters. While just using the BMS part will lose the linear time matching guarantee, it is likely to work fine on almost any real-world data set. Adapting the beta' array (KMP part) is tricky. I refer you to the MSc dissertation by Shu Wang, which discusses your question in detail:

https://macsphere.mcmaster.ca/bitstream/11375/21222/1/Wang_Shu_2005_01_master.pdf

For a more recent overview, see:

Jan Holuba, W.F.Smyth and Shu Wang. Fast pattern-matching on indeterminate strings. Journal of Discrete Algorithms: 6(1): 37-50, 2008.

https://www.sciencedirect.com/science/article/pii/S1570866706000967

CGJennings avatar Oct 15 '20 13:10 CGJennings

It is fairly easy to extend the delta array (BMS part) to support indeterminate letters. While just using the BMS part will lose the linear time matching guarantee, it is likely to work fine on almost any real-world data set. Adapting the beta' array (KMP part) is tricky. I refer you to the MSc dissertation by Shu Wang, which discusses your question in detail:

https://macsphere.mcmaster.ca/bitstream/11375/21222/1/Wang_Shu_2005_01_master.pdf

For a more recent overview, see:

Jan Holuba, W.F.Smyth and Shu Wang. Fast pattern-matching on indeterminate strings. Journal of Discrete Algorithms: 6(1): 37-50, 2008.

https://www.sciencedirect.com/science/article/pii/S1570866706000967

I also think this is a problem; can you give me an example; preferably C/C++

fyozt avatar Dec 14 '20 23:12 fyozt