0

Is there a way or some sort of library that lets you compare string easily? It's difficult to explain, but here's an example:

str = "Hi World!"

if str == "(Hello | Hi) World!":
   print("You said either 'Hi World!' or 'Hello World!'")

In this example (of course, it wouldn't actually work,) if the string is either 'Hi World!' or 'Hello World!,' then it would return True. I am pretty sure that there's a name for this, but I am not sure what it is.

1 Answers1

0

There are some libraries focused on natural language processing that can help you achieve what you want.. that really depends on the complexity of what you want to build.

NLTK - provides several features and is pretty easy to use

However, for the specific case you've mentioned, might be the case of using a spell check or see edition distance for pre-loaded close words