Wow, I really am full of horrid questions today.
I have a dictionary with a list of patterns:
Where the "." character means any pattern - this can easily be changed to the "*" symbol if need be.
When the user submits a word, I want to be able to look for a corresponding pattern (if it exists). For example if the user said "show" or "shoe", then the value 6 would be returned. If it was "band", "land", "sand", "pant" etc then 78 would be returned - but not "pants" as it is longer than the pattern.
I know the normal way is to provide the reg exp and search the dictionary with it, but this is the other way round :(
Thanks
I have a dictionary with a list of patterns:
Code:
>>> words = {'sho.':6, '.ilk':8,'.an.':78 }
When the user submits a word, I want to be able to look for a corresponding pattern (if it exists). For example if the user said "show" or "shoe", then the value 6 would be returned. If it was "band", "land", "sand", "pant" etc then 78 would be returned - but not "pants" as it is longer than the pattern.
I know the normal way is to provide the reg exp and search the dictionary with it, but this is the other way round :(
Thanks
Comment