This is a little different from most trie problems on stackoverflow (yes, I've spent time searching and reading), so please bear with me.
I have FILE A with words like: allow*, apolog*, etc. There are in total tens of thousands of such entries. And I have FILE B containing a body of text, with up to thousands of words. I want to be able to match words in my text in FILE B with words in FILE A.
Example:
FILE B's "apologize" would match FILE A's "apolog*"
FILE B's "a" would neither match "allow*" nor "apolog*"
FILE B's "apologizetomenoworelseiwillkillyou" would also match FILE A's "apolog*"
Could anyone suggest an algorithm/data structure (that is preferably do-able in python) that could help me in achieving this? The tries I've looked into seem to be more about matching prefixes to whole words, but here, I'm matching whole words to prefixes. Stemming algorithms are out of the question because they have fixed rules, whereas in this case my suffix can be anything. I do not want to iterate through my entire list in FILE A, because that would take too much time.
If this is confusing, I'm happy to clarify. Thanks.