Skip to content Skip to sidebar Skip to footer

How To Recognize Chinese Or English Name Using Python

Given a bunch of names, how can we find out which are Chinese names and which are English names? For the Chinese names, I build a list of the Chinese last names to find out the Chi

Solution 1:

If you have the lists of typical Chinese and English names and the problem is performance only, I suggest you convert the lists into sets and then ask for membership in both sets as this is much faster than finding out whether an element is present in a large list.

Solution 2:

Well, that's a pickle.

If the professor's names were written in Chinese, the obvious answer would be to check each character in the name. This answer gives us a clue that many commonly-used unicode "chinese" characters are in the range 19968 - 40959.

Thus:

def is_chinese(var):
    iford(var) >= 19968 and ord(var) <= 40959:
        return True

If your hypothetical Chinese professors have their names written using characters in those ranges somewhere in their bio, you need only search for a few characters in that range to get a reasonable answer.

However, if you already have a list of Chinese names, @SheepPerplexed has probably supplied the quickest way.

Post a Comment for "How To Recognize Chinese Or English Name Using Python"