dronefly-garden / dronefly

Red Discord Bot V3 cogs for naturalists.
Other
16 stars 3 forks source link

taxon: handle "of" as non-keyword in middle of phrase #149

Closed synrg closed 3 years ago

synrg commented 3 years ago

The query ,t chicken of the woods unexpectedly returns Verbascum thapsus (wooly mullein) (Charmin of the woods). Apparently, of is treated as a keyword. However, in this context, where the words preceding "of" aren't part of another option, it makes no sense to treat it as a keyword. Therefore, the natural language query parser should treat it as a non-keyword instead so that the expected result, Laetiporus sulphureus (chicken of the woods) will be found instead.

This could be achieved in two passes:

Expected outputs for example queries following the above steps:

,t chicken -> ,t chicken ,obs of chicken -> ,obs --of chicken ,t chicken of the woods -> ,t --of chicken of the woods ,obs by me of chicken -> ,obs --by me --of chicken ,obs by me of chicken of the woods -> ,obs --by me --of chicken of the woods

synrg commented 3 years ago

Thanks, @Riviera, for drawing this to my attention on iNat Discord.

synrg commented 3 years ago

It would be cleaner to handle this left-to-right in one pass, i.e.

synrg commented 3 years ago

Fixed by f5a10b3f2fa2ee574fc5fc44ca648bca8b2aabf5