简体   繁体   中英

String completion and matching algorithm

You have two sets: S1={B,C,D,T,M,...} and S2={with each other letter of alphabet not present in S1}. Now, I have some string constructed with consonants from S1 (ie. BBWRD) which I want to be transformed into words/sentences based of provided dictionary (ie. dict from spelling mechanism). Algorithm can fill spaces between each of letter in 'base word' with any amount of letters from S2. Order can't be changed and letters/consonants from S1 can't be used.

The only thing that came to my mind is usage of regexp. Can you propose any other, better approach? Or at least give name to this kind of algorithms, so I could search further.

I'd think about creating a search tree. Each node would have |S1| subnodes and leaves would contain a list of possible words, which may be constructed from a given acronym (such that - for example = D on the path W->R->D would contain "Word". Searching in such tree would be pretty fast, though it would require a noticeable amount of memory to be stored for quick access.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM