How can i use RegEx to search for an output inside a dictionary?
I have a code that creates a dictionary based on a csv file, using Pandas. This allows me to browse for an answer from a user input.
Example of my code:
The user sends a message that is exactly as a text in df column 'msg' (this is input) The dictionary browses on column 'reply' for an answer according to users input. (this is output)
User sends "Jeff Bezos" (which is in column 'msg') Reply output "Jeff Bezos is the CEO of Amazon" (which is in column 'reply')
df = pd.read_csv(r'My_Path.csv', error_bad_lines=False)
d = defaultdict(lambda: 'Sorry, input not listed')
d.update(df.set_index('msg')['reply'].to_dict())
....
#This uses the 'reply' column to reference my output and send_keys on Selenium
output.send_keys(d[last_msg()])
My question:
How can i use RegEx to improve the search in column 'msg' from an user input, so i can get a 'reply' output? The code above requires for the user to send a messaage exactly according to the 'msg' column to give the expected answer. I would like to search with a partial and the exact input as well.
Exemple:
User sends "Jeff" or "Bezos" or "Jeff Bezos"
Reply output "Jeff Bezos is the CEO of Amazon"
--
If i am too loose on the description, i can edit for a better understanding.