glassleo / Paragon

A World of Warcraft addon
MIT License
4 stars 1 forks source link

Faction search command: Add partial string matching against faction names and shorthands #9

Closed tflo closed 9 months ago

tflo commented 9 months ago

I really appreciate your efforts to make life easier for folks with poor memory like me with your shorthands for misspelled faction names (e.g. your incredibly creative variations for Soridormi: sidormi, sorimi, soridimi, sorimidi, sorimorni, simordi, siridorm, sidorm 😁 ).

But often, I still end up typing in a faction name 3 times or so.

Maybe it's just me, but when I forget the correct faction name, I usually remember certain parts of the faction name correctly. For example, with "Proudmoore Admiralty", I sometimes forget that "proudmoore" has a double "o", and sometimes I forget what the second word is ("admiralty"). But, for some reason, I always remembered and remember "proudm"!

So, if I can just type in any letter sequence of the name ("proudm" in the example), then the problem is solved for me forever.

Hence the idea to extend your system a bit, in form of additional partial string matching against (and with this priority)...

  1. the true faction name
  2. the shorthands

I'm pretty sure you considered this approach as well, but for some reason decided not to implement it. So, in order not to interfere with your full-string faction name and shorthand system, I added the two searches after any existing matching system:

If we get a hit with the full faction string, a full shorthand string, or the guild name, the additional partial searches are not performed at all.[^1]

For testing, you can uncomment the two debug prints in the code, which will give you insight like this:

Screenshot of Wow at Jan 28, 2024 at 00_14_04 copy

Disclaimer: This is only tested relatively shortly, but since the only modified part is the slash function, I think there is not too much bug potential.

[^1]: Both searches are simple plain-matches. Activating Lua patterns would be another possibility, but I don't think it is necessary .

glassleo commented 9 months ago

Ideally I would like there to be a better way to bring up the interface without having to type a slash command at all, but this seems pretty cool (and there's no harm in having both anyway)

glassleo commented 9 months ago

I will test this a bit more locally but from what I can tell it looks good and I'll include it in the next release most likely

tflo commented 9 months ago

Ideally I would like there to be a better way to bring up the interface without having to type a slash command

Yes, I have seen your "Redesign" issue, but I don't see a relation here.

My proposal is just about making the search more permissive (aka less frustrating 😉). If you're going to really overhaul the GUI, then see it as an interim improvement, and if you like it, you can adapt it to the new GUI later.

By the way, I have no issues with the current GUI and the access via slash commands at all 🙂

glassleo commented 9 months ago

Had to change some of the code in your commit to loop through T.factions rather than the locale table since the latter is not reliable, but other than that it looks really good! Thanks!

tflo commented 9 months ago

T.factions rather than the locale table

Oh, I took the one from Locale.lua because I had the impression you were preparing for translations (see comment in line 148 in Locale.lua). But yes, if it will not be localized to other languages, then T.factions is easier, since there is no f<space> to remove from the faction keys :)

other than that it looks really good

Glad to hear that you like it!

I've been using it for about 5 days now and it's really easier and faster for me to find a faction. Since the substring matches also against your numerous shorthands, it almost feels like a Fuzzy Search now.


PS:

Speaking about fuzzy search, I just found fzy-lua. Looks interesting, but probably overkill for only ~190 faction names…


PS2:

Just found your new release, and it seems I misread your comment above. Actually you are still using the localized names, but via the keys from T.factions. Makes sense.

glassleo commented 9 months ago

I've been using it for about 5 days now and it's really easier and faster for me to find a faction. Since the substring matches also against your numerous shorthands, it almost feels like a Fuzzy Search now.

Yeah it actually makes a huge difference, I love it!

Just found your new release, and it seems I misread your comment above. Actually you are still using the localized names, but via the keys from T.factions. Makes sense.

I was tired when I posted that last night so it maybe didn't make much sense haha. The problem with looping through the locale table is that all keys are not always available since it has a metatable function. It took me a while to figure out why /par choo was only working after having used /par choofa after a reload.