cannawen / metric_units_reddit_bot

Reddit bot converting imperial units to metric units
https://www.reddit.com/user/metric_units
GNU General Public License v3.0
78 stars 34 forks source link

Keyword triggers for fl oz instead of oz conversions #43

Closed eliotw closed 6 years ago

eliotw commented 6 years ago

Given a post contains the unit "oz" but NOT "fl oz" unit If the post text also contains the keywords:

liquid, water, tea, beer, soda, cider, juice, coffee, liquor, milk, bottle, spirits, rum, vodka, tequila, etc...

The "oz" should be converted to "fl oz" This can be done in a pre-processing step in the fl oz conversion object

eliotw commented 6 years ago

I wonder if the scope of this should be limited to a single line/sentence. There maybe a case where a recipe will reference oz for something like a steak. But then reference a liquid later on. For example:

  • 8 oz steak
  • 2 tbsp olive oil

I can work on this.

cannawen commented 6 years ago

Great, thanks for volunteering! You can find the relevant part of the code in this file. Feel free to reach out if you need any assistance :)

Can you clarify what you mean about limiting the scope to a line or sentence? In the above example you mentioned, the 8 oz should be considered a weight unit, and not volume.

eliotw commented 6 years ago

Yes. So with the previous exmaple, the original logic would require two conditions to be true.

  1. The post contains "oz" but not "fl oz"". This is true.
  2. The post contains some liquid word. This could be satisfied by the word oil. However the oz was referring to the steak not the oil. But since the scope of where we are matching is the entire post, this condition would be satisfied.

Even limiting the scope of the match to a single line/sentence could be an issue if someone posted "8 oz steak and 1 tbsp olive oil"

cannawen commented 6 years ago

Oh, I see what you mean (my mind didn't register that oil was a liquid - in my defence, it's late here, haha)... Yes, that's an excellent idea to limit it per line or sentence! Great catch :)

Hmm, you're right, there are definitely limitations to the approach. I think we should try it out, and we can always iterate if it doesn't work. I'm guessing/hoping the "8 oz steak and 1 tbsp olive oil" problem will be a super edge case