mknepprath / lilt

A Twitter text adventure.
https://botsin.space/@lilt
2 stars 1 forks source link

Improve string parsing for moves #2

Open mknepprath opened 4 years ago

mknepprath commented 4 years ago

The way tweets are getting sanitized is pretty messy and happening in multiple places right now.

  1. There's this filter_tweet(): https://github.com/mknepprath/lilt/blob/4b9efb6255688a468c46ffcc9e5dd7b283c3c009/bot.py#L145 This is lowercasing all text, removing punctuation, etc... https://github.com/mknepprath/lilt/blob/4b9efb6255688a468c46ffcc9e5dd7b283c3c009/utils.py#L48

  2. Then there are these lines that are replacing synonyms with the common lookup word used in the database: https://github.com/mknepprath/lilt/blob/4b9efb6255688a468c46ffcc9e5dd7b283c3c009/bot.py#L149

  3. And this is doing something similar... https://github.com/mknepprath/lilt/blob/4b9efb6255688a468c46ffcc9e5dd7b283c3c009/bot.py#L163

I have to be careful with these, because if I add a move to the database that includes "the" or "shopkeeper", it will never be read. For instance, if a database move record is set to "look at the shopkeeper" and a player tweets, "inspect the shopkeeper," one would expect that to match - except the bot's sanitizing code will update the player's tweet to "look at merchant" and will never match that database record. In fact, if a database record includes "the," it will always be ignored, because "the" is always removed from tweets before lookup rn.

Acceptance Criteria