check if a name seems “human”?

柔情痞子 提交于 2019-12-12 08:26:39

问题


I have an online RPG game which I'm taking seriously. Lately I've been having problem with users making bogus characters with bogus names, just a bunch of different letters. Like Ghytjrhfsdjfnsdms, Yiiiedawdmnwe, Hhhhhhhhhhejejekk. I force them to change names but it's becoming too much. What can I do about this?

Could I somehow check so at least you can't use more than 2 of the same letter beside each other?? And also maybe if it contains vowels


回答1:


I would recommend concentrating your energy on building a user interface that makes it brain-dead easy to list all new names to an administrator, and a big fat "force to rename" mechanism that minimizes the admin's workload, rather than trying to define the incredibly complex and varied rules that make a name (and program a regular expression to match them!).

Update - one thing comes to mind, though: Second Life used to allow you to freely specify a first name (maybe they check against a database of first names, I don't know) and then gives you a selection of a few hundred pre-defined last names to choose from. For an online RPG, that may already be enough.




回答2:


You could use a metaphone implementation and then look for "unnatural" patterns:

http://www.php.net/manual/en/function.metaphone.php

This is the PHP function for metaphone string generation. You pass in a string and it returns the phonetic representation of the text. You could, in theory, pass a large number of "human" names and then store a database of valid combinations of phonemes. To test a questionable name, just see if the combinations of phonemes are in the database.

Hope this helps!




回答3:


What if you would use the Google Search API to see if the name returns any results?




回答4:


I say take @Unicron's approach, of easy admin rejection, but on each rejection, add the name to a database of banned names. You might be able to use this data to detect specific attacks generation large numbers of users based on patterns. Will of course be very difficult to detect one-offs.




回答5:


Would limiting the amount of consonants or vowels in a row, and preventing repeating help? As a regex:

if(preg_match('/[bcdfghjklmnpqrtsvwxyz]{4}|[aeiou]{4}|([a-z])\1{2}/i',$name)){
    //reject
}

Possibly use iconv with ASCII//TRANSLIT if you allow accentuated characters.




回答6:


I had this issue as well. An easy way to solve it is to force user names to validate against a database of world-wide names. Essentially you have a database on the backend with a few hundred thousand first and last names for both genders, and make their name match.

With a little bit of searching on google, you can find many name databases.




回答7:


Could I somehow check so at least you cant use more than 2 of the same letter beside each other?? and also maybe if it contains vowels

If you just want this, you can do:

preg_match('/(.)\\1\\1/i', $name);

This will return 1 if anything appears three times in a row or more.




回答8:


This link might help. You might also be able to plug it through a (possibly modified) speech synthesiser engine and analyse how much trouble it's having generating the speech, without actually generating it.




回答9:


You should try implementing a modified version of a Naive Bayes spam filter. For example, in normal spam detection you calculate the probability of a word being spam and use individual word probabilities to determine if the whole message is spam.

Similarly, you could download a word list, and compute the probability that a pair of letters belongs to a real word.

E.g., create a 26x26 table say, T. Let the 5th row represent the letter e and let entry T(5,1) be the number of times ea appeared in your word list. Once you're done counting, divide each element in each row with the sum of the row so that T(5,1) is now the percentage of times ea appears in your word list in a pair of letter starting with e.

Now, you can use the individual pair probability (e.g. in Jimy that would be {Ji,im,iy} to check whether Jimy is an acceptable name or not. You'll probably have to determine the right probability to threshold at, but try it out --- it's not that hard to implement.




回答10:


What do you think about delegating the responsibility of creating users to a third party source (like Facebook, Twitter, OpenId...)?

Doing that will not solve your problem, but it will be more work for a user to create additional accounts - which (assuming that the users are lazy, since most are) should discourage the creation of additional "dummy" users.




回答11:


It seems as though you are going to need a fairly complex preg function. I don't want to take the time to write one for you, as you will learn more writing it yourself, but I will help along the way if you post some attempts.

http://php.net/manual/en/function.preg-match.php



来源:https://stackoverflow.com/questions/3258688/check-if-a-name-seems-human

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!