Currently, the mentioning system does match for characters in any order, for example:
@ose will match a user that is named someuser
I don't think its a smart system.
I would suggest, that instead, mentions only strictly matches on sequences, and only for sequences that begin on the same letters as the mention, for example:
@som should match someuser, but not @ose or @ome.
To make the mention system smarter, I would also suggest a fuzzing algoritm, that will weight the mentions according to the Place of the letters on keyboard, so if I accidentially write for example @aom instead of @som because a and s is Close to each other on keyboard, it should still match "someuser".
However, the fuzzy matches should be third priority, first priority should be exact matches on server nick, in server rank order, second priority should be account nick, in server rank order, then third priority should be fuzzy matches, both on server nick and account nick, but in order of how "far" away the fuzzy match is from the real exact match counted by how Close the characters are on keyboard, if theres a tie on server nick and account nick, let the user with match on server nick, come first.
Also, it shouldn't match in the middle of someone's nick unless theres a reason for this, for example if someone has a space or Another non-alphanumeric character in their nick that would become a natural split.
I would suggest splitting up the nick based on non-alphanumeric characters, and then matching mentions on the splitted parts.
So if someone has the nick:
[SuperTeam]Nice Large Guy
I can mention him either by (some examples, so you understand the general idea)
Technically, you would replace every character in nick that isn't a number or letter (A-Z 0-9), with a space, compress all multiple spaces next to each other to one single space, and then you chomp(); the nick, and then split it on each space.
So the above nick example would become a Array like ('SuperTeam', 'Nice', 'Large', 'Guy'); that is then used in the mentioning algoritm.
Could become weird in non-English languages, but could be solved by just ignoring non-English characters in @-mentions, then it will just magically work. (unless the nick solely contains non-English characters)
By combining such a mentioning algoritm that "anchors" each mention to each Word in a nick, splitted by a non-alphanumeric character, with a "fuzzing" algoritm that will detect simple misspellings by looking on how Close certain characters is on the keyboard, I think the mentioning system could become great, and also pick up on user's intent much better.
댓글을 남기려면 로그인하세요.