Reputation: 460
I have a response system, and I'm trying to get it so you can input a String, and it matches it to the most likely String in its database by looping through each one and measuring the Levinshtein Distance with predefined questions and using a few other algorithms.
Example: If you input "Hi, how are you?" It will search its database for something identical or very similar (like "Hi, how are you doing?"). But I want it to be able to detect if a specific phrase that depends on the circumstances is being used, such as:
"Give me 10 cookies." Now, I don't want to add all possible numbers of cookies in the database. That would be impossible. So, in the database, it would be something like:
"Give me [number] cookies." How would I detect the pattern though? Keep in mind I'm also going to be using String patterns for other responses.
Upvotes: 0
Views: 79
Reputation: 19
It's not possible using regular expressions to solve this problem. Regular expressions represents regular grammar you need a context-sensitive grammar parser for this purpose.
Upvotes: 1