codidact / qpixel

Q&A-based community knowledge-sharing software
https://codidact.com
GNU Affero General Public License v3.0
385 stars 69 forks source link

Add friction for probably-duplicate tags like singular/plural #1241

Open cellio opened 9 months ago

cellio commented 9 months ago

meta:288738

Currently, anyone who can post can create new tags by typing them into the tags part of the editor. We have good auto-suggestions but still, sometimes people manage to create, say, the singular form of an existing plural tag (like "tag" vs "tags"). Can we put some extra checks around that? I'm imagining an interface where the system says "did you mean (other tag)?" and the options are "yes" (use that) or "no, I really do mean this new very similar tag" (create it).

At minimum, it should trigger if the new tag is an initial substring of another tag. I don't know how practical it is to also catch "almost substrings" like with "y"/"-ies" singular/plural variants; that might not be worth the additional complexity.

Oaphi commented 9 months ago

@cellio if we are feeling fancy, we can calculate edit distance and suggest a limited set of tags with low distance. At least with the Levenstein distance (a library can handle most of the workload, plus it's relatively easy to implement manually too) algorithm. A trie implementation would be better, but also significantly more complex (if anyone knows of a good library to avoid manually implementing one, let me know).

A naive implementation of just checking if the tag name is an initial substring of another tag would only be annoying to users, methinks (or, best case scenario, a constant source of amusing suggestions).