wolph / alfred-converter

Alfred unit converter is a smart calculator for Alfred with support for unit conversions to make it a bit comparable to the Google Calculator and Wolfram Alpha.
93 stars 15 forks source link

Add unit aliases to keyword matches #44

Closed aaronkollasch closed 1 year ago

aaronkollasch commented 1 year ago

Hi again,

If I enter "10 pounds to ounce", I only see one result, "160 ounce mass". However, if I enter "100 pounds to ounces", I see all units instead of just ounces. This seems to be because the Unit.others(self, keyword=None) function does not check for keyword matches to unit aliases (annotations) before outputting the full list of units. This also applies to other units with aliases (foot/feet, lb/lbs, litre/liter/liters, gigabyte/GB, etc.).

This PR adds to Unit.others() a check for an exact match of the keyword to any of the annotations when generating the filtered list new_tos.

wolph commented 1 year ago

That's a nice improvement, thank you :)