Settings

Theme

Ask HN: How to easily check if two words are too close

2 points by data37 9 years ago · 5 comments · 1 min read


I have a comments section for my web site. But I didn't setup a signup or email validation for posting comments.

Now the issue is, when people ask questions I would like to answer as the site admin, but what if someone else also posts a comment using my username?

The strategy I'm thinking:

If someone tries to post with the site admin username, the code rejects it saying that the username is reserved. Site admin would add a comment using a username which is actually a password. The code checks the username, and if matches this password, then it uses a standard site admin name for the comment.

But it may be difficlut to check for slight variations of the admin username. Is there any library which can test if some word or phrase is too close to a given word?

niftich 9 years ago

You're looking for Levenshtein distance [1] or a similar string distance algorithm.

[1] https://en.wikipedia.org/wiki/Levenshtein_distance

data37OP 9 years ago

aha - got another idea. I'll just use a different format to display the admin comments. So the imposter can't mimic the format, though they can use the same username.

  • niftich 9 years ago

    This is frequently done on (pseudonymous) imageboards, as well as chatrooms and the like. The admins have a password/key that when provided, enables them to be displayed differently, like an additional image tag, or a separate nearby text element saying [ADMIN].

    This is coded into the server-side site code, and normal users are not able to inject content into that other element to masquerade as admin.

ankurdhama 9 years ago

The search keyword is "Fuzzy string matching".

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection