add is_asian_name
This commit is contained in:
parent
4677188407
commit
b905003a9e
1 changed files with 57 additions and 0 deletions
57
ox/text.py
57
ox/text.py
|
@ -18,6 +18,51 @@ ARTICLES = list(set([
|
||||||
'o', 'a', 'os', '_as', 'um', 'uma', '_uns', 'umas' # pt
|
'o', 'a', 'os', '_as', 'um', 'uma', '_uns', 'umas' # pt
|
||||||
# some _disabled because of collisions
|
# some _disabled because of collisions
|
||||||
]))
|
]))
|
||||||
|
# every given name in 0xDB that matches Xxxx-yyyy Lastname
|
||||||
|
ASIAN_FIRST_NAMES = [
|
||||||
|
'a', 'ae', 'aeng', 'ah', 'ai', 'an', 'back', 'bae', 'ban', 'bang', 'bao',
|
||||||
|
'beom', 'bi', 'bin', 'bo', 'bok', 'bon', 'bong', 'bu', 'bum', 'byeong',
|
||||||
|
'byoung', 'byung', 'cai', 'chae', 'chan', 'chang', 'chao', 'cheal', 'chen',
|
||||||
|
'cheng', 'cheol', 'cheon', 'cheong', 'cheul', 'chi', 'chia', 'chiao',
|
||||||
|
'chieh', 'chien', 'chih', 'chin', 'ching', 'cho', 'choi', 'chong', 'choo',
|
||||||
|
'chu', 'chuan', 'chuen', 'chul', 'chun', 'chung', 'chuo', 'chyi', 'da',
|
||||||
|
'dae', 'dah', 'dal', 'dan', 'deok', 'do', 'dong', 'doo', 'duek', 'duk',
|
||||||
|
'e', 'el', 'en', 'eui', 'eul', 'eun', 'eung', 'fai', 'fan', 'fang', 'fei',
|
||||||
|
'fen', 'feng', 'fo', 'foo', 'fu', 'ga', 'gae', 'gam', 'gang', 'ge', 'gen',
|
||||||
|
'geon', 'geun', 'gi', 'gil', 'gin', 'gnad', 'gok', 'goo', 'gook', 'gu',
|
||||||
|
'gun', 'gwan', 'gye', 'gyeong', 'gyu', 'gyun', 'ha', 'hae', 'hak', 'han',
|
||||||
|
'hang', 'hao', 'he', 'hee', 'heng', 'heon', 'hie', 'ho', 'hoi', 'hong',
|
||||||
|
'hoo', 'hoon', 'hou', 'hsi', 'hsiang', 'hsiao', 'hsieh', 'hsien', 'hsin',
|
||||||
|
'hsing', 'hsiung', 'hu', 'hua', 'huai', 'huang', 'hue', 'hui', 'hun',
|
||||||
|
'hung', 'hwa', 'hwan', 'hwang', 'hye', 'hyeok', 'hyeon', 'hyeong', 'hyo',
|
||||||
|
'hyuk', 'hyun', 'hyung', 'i', 'ik', 'il', 'in', 'ja', 'jae', 'jan', 'jang',
|
||||||
|
'je', 'jee', 'jen', 'jeok', 'jeong', 'jeung', 'ji', 'jia', 'jian', 'jik',
|
||||||
|
'jin', 'jing', 'jo', 'jong', 'joo', 'joon', 'ju', 'juan', 'jun', 'jung',
|
||||||
|
'ka', 'kai', 'kam', 'kan', 'kang', 'kap', 'kar', 'ke', 'kee', 'kei',
|
||||||
|
'keng', 'keum', 'keung', 'ki', 'kil', 'kin', 'kit', 'kot', 'ku', 'kua',
|
||||||
|
'kuan', 'kuang', 'kuen', 'kun', 'kuo', 'kwang', 'kwok', 'kwon', 'kwong',
|
||||||
|
'kyeong', 'kyo', 'kyoon', 'kyou', 'kyoung', 'kyu', 'kyun', 'kyung', 'lai',
|
||||||
|
'lau', 'lee', 'lei', 'leng', 'leung', 'li', 'liang', 'lien', 'lin', 'ling',
|
||||||
|
'lock', 'long', 'lun', 'lung', 'maeng', 'man', 'mei', 'mi', 'miao', 'min',
|
||||||
|
'ming', 'mo', 'mok', 'moo', 'mook', 'moon', 'mu', 'mun', 'myeong',
|
||||||
|
'myoeng', 'myong', 'myung', 'na', 'nae', 'nai', 'nam', 'nan', 'neung',
|
||||||
|
'ngaru', 'ni', 'no', 'nyeo', 'oh', 'ok', 'ou', 'pai', 'pei', 'pen', 'peng',
|
||||||
|
'pi', 'pil', 'pin', 'ping', 'po', 'pui', 'pyo', 'pyung', 'qing', 'qun',
|
||||||
|
'ra', 'rak', 'ram', 'ran', 'reum', 'ri', 'rim', 'rin', 'roe', 'rok', 'ru',
|
||||||
|
'rui', 'ryeon', 'ryol', 'ryong', 'sa', 'sae', 'san', 'sang', 'se', 'seo',
|
||||||
|
'seob', 'seok', 'seol', 'seon', 'seong', 'seung', 'shan', 'shen', 'sheng',
|
||||||
|
'shi', 'shia', 'shiang', 'shih', 'shik', 'shim', 'shin', 'shing', 'shou',
|
||||||
|
'shu', 'shun', 'si', 'sik', 'sin', 'siu', 'so', 'song', 'soo', 'sook',
|
||||||
|
'soon', 'su', 'suk', 'sun', 'sung', 'sup', 'szu', "t'ien", 'ta', 'tae',
|
||||||
|
'taek', 'tai', 'tak', 'te', 'ti', 'tian', 'ting', 'to', 'toa', 'tsai',
|
||||||
|
'tsan', 'tse', 'tso', 'tsui', 'tung', 'tzu', 'ua', 'ui', 'un', 'wah',
|
||||||
|
'wai', 'wan', 'wei', 'wen', 'weon', 'wing', 'wit', 'wol', 'won', 'woo',
|
||||||
|
'wook', 'woon', 'woong', 'wuk', 'xiao', 'ya', 'yan', 'yang', 'yao', 'ye',
|
||||||
|
'yea', 'yee', 'yeh', 'yen', 'yeo', 'yeol', 'yeon', 'yeong', 'yeop', 'yi',
|
||||||
|
'yin', 'ying', 'yiu', 'yoeng', 'yong', 'yoo', 'yoon', 'you', 'young', 'yu',
|
||||||
|
'yuan', 'yue', 'yuen', 'yuk', 'yull', 'yun', 'yune', 'yung', 'zhi',
|
||||||
|
'zhong', 'zhu'
|
||||||
|
]
|
||||||
# see http://en.wikipedia.org/wiki/List_of_common_Chinese_surnames
|
# see http://en.wikipedia.org/wiki/List_of_common_Chinese_surnames
|
||||||
# and http://en.wikipedia.org/wiki/List_of_Korean_family_names
|
# and http://en.wikipedia.org/wiki/List_of_Korean_family_names
|
||||||
ASIAN_NAMES = [
|
ASIAN_NAMES = [
|
||||||
|
@ -260,6 +305,10 @@ def get_sort_name(name):
|
||||||
def find_name(names):
|
def find_name(names):
|
||||||
return len(first_names) and first_names[-1].lower() in names
|
return len(first_names) and first_names[-1].lower() in names
|
||||||
|
|
||||||
|
if is_asian_name(name):
|
||||||
|
names = name.split(' ')
|
||||||
|
return names[-1] + ' ' + ' '.join(names[:-1])
|
||||||
|
|
||||||
first_names = name.split(' ')
|
first_names = name.split(' ')
|
||||||
last_names = []
|
last_names = []
|
||||||
if re.search('^[0-9]+$', first_names[-1]):
|
if re.search('^[0-9]+$', first_names[-1]):
|
||||||
|
@ -331,6 +380,14 @@ def find_string(string, string0='', string1=''):
|
||||||
string1 = '$'
|
string1 = '$'
|
||||||
return find_re(string, string0 + '(.*?)' + string1)
|
return find_re(string, string0 + '(.*?)' + string1)
|
||||||
|
|
||||||
|
def is_asian_name(name):
|
||||||
|
names = name.lower().split(' ')
|
||||||
|
if len(names) != 3:
|
||||||
|
return False
|
||||||
|
if names[0] in ASIAN_FIRST_NAMES and names[1] in ASIAN_FIRST_NAMES:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def parse_useragent(useragent):
|
def parse_useragent(useragent):
|
||||||
data = {}
|
data = {}
|
||||||
for key in UA_REGEXPS:
|
for key in UA_REGEXPS:
|
||||||
|
|
Loading…
Reference in a new issue