Skip to content

Instantly share code, notes, and snippets.

@lunark lunark/GenderEstimate.bas
Last active Aug 4, 2018

Embed
What would you like to do?
VBAマクロ向け関数。GenderEstimate。漢字の名前とふりがなから、性別を推定する関数
Public Function GenderEstimate(strMK As String, Optional strMF As String) As String
GenderEstimate = ""
strMK = Replace(Replace(Replace(strMK, " ", ""), " ", ""), "「", "")
strMF = Replace(Replace(StrConv(strMF, vbHiragana), " ", ""), " ", "")
'デバッグ用。こいつをブレークポイントに持ってきて挙動を確認する
'If strMK Like "理世" Then
' Debug.Print strMK
'End If
Select Case True
'ひらがなが2文字以下のものは中国人名と判断して飛ばす
Case Len(strMF) < 2
GoTo SKIPPOINT:
'----------------------------------------------
'珍名でどちらかの性別にしかありえない読みを先に弾いてしまう
'----------------------------------------------
Case strMF Like "てんこう"
GenderEstimate = "女性": GoTo SKIPPOINT
Case strMF Like "なおき"
GenderEstimate = "男性": GoTo SKIPPOINT
'----------------------------------------------
'Level1:100%男性 or 女性と言って差し支えないようなマッチ
'----------------------------------------------
'男性:名前:末尾の漢字をマッチ
Case strMK Like "*夫" Or strMK Like "*雄" Or strMK Like "*男" Or strMK Like "*朗" Or strMK Like "*郎" Or strMK Like "*比古" Or strMK Like "*彦" Or strMK Like "*麻呂" Or _
strMK Like "*麿" Or strMK Like "*満" Or strMK Like "*洋" Or strMK Like "*章" Or strMK Like "*顕" Or strMK Like "*嗣" Or strMK Like "*志" Or strMK Like "*八" Or _
strMK Like "*鷹" Or strMK Like "*一" Or strMK Like "*助" Or strMK Like "*輔" Or strMK Like "*丞" Or strMK Like "*鉄" Or strMK Like "*哲" Or strMK Like "*道" Or _
strMK Like "*通" Or strMK Like "*作" Or strMK Like "*兼" Or strMK Like "*鉄" Or strMK Like "*亮" Or strMK Like "*晃" Or strMK Like "*昭" Or strMK Like "*顕" Or _
strMK Like "*士" Or strMK Like "*行" Or strMK Like "*則" Or strMK Like "*征" Or strMK Like "*浩" Or strMK Like "*宏" Or strMK Like "*博" Or strMK Like "*之" Or _
strMK Like "*徳" Or strMK Like "*平" Or strMK Like "*兵" Or strMK Like "*介" Or strMK Like "*三" Or strMK Like "*五" Or strMK Like "*吾" Or strMK Like "*弘" Or _
strMK Like "*寛" Or strMK Like "*憲" Or strMK Like "*煕" Or strMK Like "*伍" Or strMK Like "*迫" Or strMK Like "*暢" Or strMK Like "*隆" Or strMK Like "*崇" Or _
strMK Like "*宗" Or strMK Like "*悟" Or strMK Like "*典" Or strMK Like "*馬" Or strMK Like "*武" Or strMK Like "*地" Or strMK Like "*人" Or strMK Like "*邦" Or _
strMK Like "*匡" Or strMK Like "*斗" Or strMK Like "*翔" Or strMK Like "*勝" Or strMK Like "*将" Or strMK Like "*仁" Or strMK Like "*気" Or strMK Like "*機" Or _
strMK Like "*謙" Or strMK Like "*久" Or strMK Like "*信" Or strMK Like "*延" Or strMK Like "*伸" Or strMK Like "*宣" Or strMK Like "*二" Or strMK Like "*広" Or _
strMK Like "*巳" Or strMK Like "*吉" Or strMK Like "*収" Or strMK Like "*修" Or strMK Like "*児" Or strMK Like "*秀" Or strMK Like "*基" Or strMK Like "?雅" Or _
strMK Like "*至" Or strMK Like "*慶" Or strMK Like "*啓" Or strMK Like "*磨" Or strMK Like "*次" Or strMK Like "*康" Or strMK Like "*臣" Or strMK Like "*拓" Or _
strMK Like "*輝" Or strMK Like "*彰" Or strMK Like "*俊" Or strMK Like "*峻" Or strMK Like "*駿" Or strMK Like "*祥" Or strMK Like "*視" Or strMK Like "*達" Or _
strMK Like "*富" Or strMK Like "*高" Or strMK Like "*統" Or strMK Like "*騎" Or strMK Like "*城" Or strMK Like "*斉" Or strMK Like "*靖" Or strMK Like "*雍" Or _
strMK Like "*泰" Or strMK Like "*真" Or strMK Like "*剛" Or strMK Like "*誉" Or strMK Like "*義" Or strMK Like "*範" Or strMK Like "*守" Or strMK Like "*拡" Or _
strMK Like "*治" Or strMK Like "*敏" Or strMK Like "*久" Or strMK Like "*登" Or strMK Like "*賀" Or strMK Like "*忠" Or strMK Like "*就" Or strMK Like "?卓" Or _
strMK Like "*斎" Or strMK Like "*多" Or strMK Like "*汰" Or strMK Like "*毅" Or strMK Like "*聞" Or strMK Like "*蔵" Or strMK Like "*充" Or strMK Like "*盈" Or _
strMK Like "*允" Or strMK Like "*規" Or strMK Like "*正" Or strMK Like "*揮" Or strMK Like "*儀" Or strMK Like "*孝" Or strMK Like "*峰" Or strMK Like "?親" Or _
strMK Like "?稔" Or strMK Like "*愉" Or strMK Like "?郷" Or strMK Like "*駄" Or strMK Like "*詞" Or strMK Like "*昌" Or strMK Like "*政" Or strMK Like "?旭" Or _
strMK Like "?暉" Or strMK Like "?尊" Or strMK Like "?氏" Or strMK Like "?堂" Or strMK Like "?陛" Or strMK Like "?誠" Or strMK Like "?厚" Or strMK Like "?豪" Or _
strMK Like "?進" Or strMK Like "*宝" Or strMK Like "?朝" Or strMK Like "?航" Or strMK Like "?國" Or strMK Like "?国" Or strMK Like "?頼" Or strMK Like "?経" Or _
strMK Like "?氣" Or _
(strMK Like "?望" And Not strMF Like "*み") Or (strMK Like "*己" And strMF Like "*み") Or (strMK Like "*紘" And Not strMK Like "千紘") Or _
(strMK Like "?友" And strMF Like "??とも")
GenderEstimate = "男性": GoTo SKIPPOINT
'男性:名前:どの位置にあってもマッチ
Case strMK Like "*大*" Or strMK Like "*滋*" Or strMK Like "?茂?" Or strMK Like "*陸*" Or strMK Like "*健*" Or strMK Like "*太*" Or strMK Like "*龍*" Or strMK Like "*竜*" Or _
strMK Like "*孟*" Or strMK Like "*王*" Or strMK Like "*力*"
GenderEstimate = "男性": GoTo SKIPPOINT
'男性:名前:頭にこの文字があるとマッチ
Case strMK Like "一?" Or strMK Like "脩*" Or strMK Like "勇*" Or strMK Like "皓*" Or strMK Like "岳*" Or strMK Like "玄?" Or strMK Like "建?" Or strMK Like "雄?" Or _
(strMK Like "茂?" And Not strMK Like "?[子美]")
GenderEstimate = "男性": GoTo SKIPPOINT
'男性:1文字・2文字・固定ネーム
Case strMK Like "誠" Or strMK Like "徹" Or strMK Like "悟" Or strMK Like "覚" Or strMK Like "航" Or strMK Like "亘" Or strMK Like "渉" Or strMK Like "篤" Or _
strMK Like "中" Or strMK Like "隆" Or strMK Like "崇" Or strMK Like "豊" Or strMK Like "豪" Or strMK Like "剛" Or strMK Like "敦" Or strMK Like "懿" Or _
strMK Like "勝" Or strMK Like "翔" Or strMK Like "将" Or strMK Like "強" Or strMK Like "仁" Or strMK Like "慎" Or strMK Like "匠" Or strMK Like "巧" Or _
strMK Like "卓" Or strMK Like "拓" Or strMK Like "涼" Or strMK Like "聡" Or strMK Like "慧" Or strMK Like "健" Or strMK Like "新" Or strMK Like "充" Or _
strMK Like "晟" Or strMK Like "栄" Or strMK Like "凱" Or strMK Like "厚" Or strMK Like "弦" Or strMK Like "甫" Or strMK Like "創" Or strMK Like "隼" Or _
strMK Like "司" Or strMK Like "学" Or strMK Like "曜" Or strMK Like "耀" Or strMK Like "直" Or strMK Like "理" Or strMK Like "立" Or strMK Like "吏" Or _
strMK Like "護" Or strMK Like "衛" Or strMK Like "敬" Or strMK Like "格" Or strMK Like "築" Or strMK Like "麟" Or strMK Like "楽" Or strMK Like "錬" Or _
strMK Like "類" Or strMK Like "塁" Or strMK Like "奨" Or _
strMK Like "朋央" Or strMK Like "達望" Or strMK Like "信貴" Or strMK Like "康貴" Or strMK Like "瑠偉" Or strMK Like "博文" Or strMK Like "敏生" Or _
strMK Like "裕[幸己喜将將]" Or strMK Like "貴[幸己喜将將]" Or _
(strMK Like "裕貴" And Not strMF Like "ゆき") Or (strMK Like "尚" And strMF Like "ひさし")
GenderEstimate = "男性": GoTo SKIPPOINT
'女性:名前:末尾をマッチ
Case strMK Like "*子" Or strMK Like "*奈" Or strMK Like "*那" Or strMK Like "*菜" Or strMK Like "*衣" Or strMK Like "*依" Or strMK Like "*弓" Or _
strMK Like "*桐" Or strMK Like "*華" Or strMK Like "*加" Or strMK Like "*恵" Or strMK Like "*歌" Or strMK Like "*絵" Or strMK Like "*恵" Or _
strMK Like "*織" Or strMK Like "*乃" Or strMK Like "*音" Or strMK Like "*苗" Or strMK Like "*莉" Or strMK Like "*捺" Or strMK Like "*亜" Or _
strMK Like "*梨" Or strMK Like "*枝" Or strMK Like "*姫" Or strMK Like "?麗" Or strMK Like "*江"
GenderEstimate = "女性": GoTo SKIPPOINT
'女性:名前:どの位置にあってもマッチ
Case strMK Like "*花*" Or strMK Like "*愛*" Or strMK Like "*妃*" Or strMK Like "*紗*" Or strMK Like "*沙*" Or strMK Like "*桜*" Or _
strMK Like "*百合*" Or strMK Like "*杏*" Or strMK Like "*萌*"
GenderEstimate = "女性": GoTo SKIPPOINT
'女性:頭にこの文字があるとマッチ
Case strMK Like "亜希*" Or strMK Like "亜紀*" Or strMK Like "桃*" Or strMK Like "菫*" Or strMK Like "茉*" Or strMK Like "絢*" Or strMK Like "菜*" Or strMK Like "奈*" Or _
strMK Like "木綿*" Or strMK Like "芽*" Or strMK Like "笑*"
GenderEstimate = "女性": GoTo SKIPPOINT
'女性:1文字・固定ネーム
Case strMK Like "美佳" Or strMK Like "美嘉" Or strMK Like "舞" Or strMK Like "凛" Or strMK Like "朱" Or strMK Like "茜" Or strMK Like "彩" Or strMK Like "栞" Or _
strMK Like "美紀" Or strMK Like "あおい" Or strMK Like "紫" Or strMK Like "弥生" Or strMK Like "環" Or strMK Like "伊世" Or strMK Like "咲" Or strMK Like "晶"
GenderEstimate = "女性": GoTo SKIPPOINT
'----------------------------------------------
'Level2:漢字の読みや文字長によって男女判定が変わる可能性のあるもの
'上記でマッチングできなかったものがここに到達します。
'----------------------------------------------
'世 の判定、末尾を「せい」と読む場合は男性
Case strMK Like "*世"
If strMF Like "りよ" Then GenderEstimate = "女性"
If strMF Like "*せい" Then GenderEstimate = "男性"
GoTo SKIPPOINT
'尚 の判定
Case strMK Like "*尚"
If strMF Like "??ひさ" Then GenderEstimate = "男性"
If strMF Like "??たか" Then GenderEstimate = "男性"
If strMF Like "??なお" Then GenderEstimate = "男性"
GoTo SKIPPOINT
'生 の判定
Case strMK Like "?生" Or strMK Like "??生"
If strMF Like "*なり" Then GenderEstimate = "男性"
If strMF Like "*お" Then GenderEstimate = "男性"
GoTo SKIPPOINT
'瑛 の判定
Case strMK Like "?瑛"
If strMF Like "??あき" Then GenderEstimate = "男性"
GoTo SKIPPOINT
'司 の判定、読みが「し」「じ」で終わる場合のみ男性を判定
Case strMK Like "*司"
If strMF Like "*し" Or strMF Like "*じ" Then GenderEstimate = "男性": GoTo SKIPPOINT
'成 の判定、読みが「な」で終わる場合は女性、「なり」「あき」で終わる場合は男性
Case strMK Like "*成"
If strMF Like "*な" Then GenderEstimate = "女性"
If strMF Like "*なり" Then GenderEstimate = "男性"
If strMF Like "*あき" Then GenderEstimate = "男性"
If strMF Like "*しげ" Then GenderEstimate = "男性"
If strMF Like "*せい" Then GenderEstimate = "男性"
GoTo SKIPPOINT
Case strMK Like "成?" Or strMK Like "成??"
If strMF Like "しげ*" Then GenderEstimate = "男性"
If strMF Like "せい*" Then GenderEstimate = "男性"
If strMF Like "なるみ" Then GenderEstimate = "女性"
GoTo SKIPPOINT
'幸 の判定、よみが「さち」「ゆき」で終わるか「まゆき」「みゆき」の場合のみ女性、その他の「ゆき」で終わるパターンは男性
Case strMK Like "*幸"
If strMF Like "*ゆき" Then GenderEstimate = "男性"
If strMF Like "[まみさ]ゆき" Then GenderEstimate = "女性"
If strMF Like "さち" Or strMF Like "ゆき" Then GenderEstimate = "女性"
GoTo SKIPPOINT
'美 の判定、「よし」で終われば男性、「み」で終われば女性
'美ではじまる苗字の場合も同様
Case strMK Like "*美"
If strMF Like "*よし" Then GenderEstimate = "男性"
If strMF Like "*み" Then GenderEstimate = "女性"
GoTo SKIPPOINT
Case strMK Like "美*"
If strMF Like "よし*" Then GenderEstimate = "男性"
If strMF Like "み*" Then GenderEstimate = "女性"
GoTo SKIPPOINT
'文 の判定、「ふみ」で終わる場合のみ男性、「あや」で終わる場合のみ女性
Case strMK Like "*文"
If strMF Like "*ふみ" Then GenderEstimate = "男性"
If strMF Like "*あや" Then GenderEstimate = "女性"
GoTo SKIPPOINT
'也 の判定、「なり」の読み終わりは男性だが、「や」で終わる場合は複雑です
Case strMK Like "*也"
If strMF Like "*なり" Then GenderEstimate = "男性": GoTo SKIPPOINT
If strMF Like "*や" Then
If strMF Like "美?" Then GoTo SKIPPOINT '「美」ではじまるときはエスケープさせます
If strMF Like "まや" Then GenderEstimate = "女性": GoTo SKIPPOINT '「まや」という名前の場合は女性
If strMF Like "かや" Then GenderEstimate = "女性": GoTo SKIPPOINT '「かや」という名前の場合は女性
If strMF Like "さや" Then GenderEstimate = "女性": GoTo SKIPPOINT '「かや」という名前の場合は女性
GenderEstimate = "男性" 'それ以外の場合、男性です。
End If
'明 の判定、「あき」で終われば男性だが、「ちあき」の場合は男女比が難しい為予め処理を避ける。
'「あかり」と読む場合は女性
Case strMK Like "?明"
If strMF Like "ちあき" Then GoTo SKIPPOINT
If strMF Like "*あき" Then GenderEstimate = "男性": GoTo SKIPPOINT
Case strMK Like "??明"
If strMF Like "*あき" Then GenderEstimate = "男性": GoTo SKIPPOINT
Case strMK Like "明"
If strMF Like "あかり" Then GenderEstimate = "女性": GoTo SKIPPOINT
If strMF Like "あきら" Then GenderEstimate = "男性": GoTo SKIPPOINT
'弥 も判定したいですが全力で逃げます。名前で判定する。
Case strMK Like "?弥"
If strMF Like "*なり" Then GenderEstimate = "男性": GoTo SKIPPOINT
If strMF Like "*や" Then
If strMF Like "美?" Then GenderEstimate = "女性": GoTo SKIPPOINT '「美」ではじまるときはは女性
If strMF Like "まや" Then GenderEstimate = "女性": GoTo SKIPPOINT '「まや」という名前の場合は女性
If strMF Like "かや" Then GenderEstimate = "女性": GoTo SKIPPOINT '「かや」という名前の場合は女性
If strMF Like "さや" Then GenderEstimate = "女性": GoTo SKIPPOINT '「かや」という名前の場合は女性
GenderEstimate = "男性" 'それ以外の場合、男性です。
End If
'史 の判定、「ふみ」「し」「じ」「ちかし」で終われば男性、「ふみ」で始まると女性
Case strMK Like "史"
If strMF Like "ちかし" Then GenderEstimate = "男性": GoTo SKIPPOINT
If strMF Like "ふみ" Then GenderEstimate = "女性": GoTo SKIPPOINT
Case strMK Like "?史"
If strMF Like "*ふみ" Or strMF Like "*し" Or strMF Like "*じ" Or strMF Like "*と" Then GenderEstimate = "男性": GoTo SKIPPOINT
Case strMK Like "??史"
If strMF Like "*ふみ" Or strMF Like "*し" Or strMF Like "*じ" Then GenderEstimate = "男性": GoTo SKIPPOINT
Case strMK Like "史?"
If strMF Like "*ふみ" Then GenderEstimate = "女性": GoTo SKIPPOINT
'良 の判定、「ら」を女性に、「よし」で終われば男性に。ただし「あきら」「たいら」という名前に良の文字を使う場合は100%男性なのでエスケープする
'これ以外の読み方をするときはとりあえず男性に。
Case strMK Like "*良"
If strMF Like "あきら" Or strMF Like "たいら" Then GenderEstimate = "男性": GoTo SKIPPOINT
If strMF Like "*よし" Then GenderEstimate = "男性": GoTo SKIPPOINT
If strMF Like "*ら" Then GenderEstimate = "女性": GoTo SKIPPOINT
GenderEstimate = "男性"
'見 の判定、「なみ」と読ませるときは女性、それ以外は男性に割り当て
Case strMK Like "*見"
If strMF Like "なみ" Then GenderEstimate = "女性": GoTo SKIPPOINT
GenderEstimate = "男性"
'裕 の判定、「ちひろ」の名前の一部として使われる場合は女性、それ以外は男性に割り当て。
'もしかしたら「ゆう」に対する使い分けが必要かもしれません
Case strMK Like "*裕"
If strMF Like "ちひろ" Then GenderEstimate = "女性": GoTo SKIPPOINT
GenderEstimate = "男性"
'樹 の判定、ちょっと複雑です
Case strMK Like "*樹"
If strMF Like "みずき" Then GoTo SKIPPOINT '「みずき」という名前の一部の場合はスキップさせる。
If strMK Like "美*" Then GenderEstimate = "女性": GoTo SKIPPOINT '「美」が名前の先頭である場合は女性
If strMF Like "さき" Then GenderEstimate = "女性": GoTo SKIPPOINT '「さき」という名前の一部の場合は女性
If strMF Like "かずき" Then GenderEstimate = "男性": GoTo SKIPPOINT '「かずき」という名前の一部の場合は男性
If strMF Like "*じゅ" Then GenderEstimate = "男性": GoTo SKIPPOINT '「じゅ」という読み終わりの場合男性
If strMF Like "*き" Then GenderEstimate = "男性": GoTo SKIPPOINT '「き」という読み終わりの場合男性
'利 の判定「あぐり」でもこの字の場合のみ男性です。
Case strMK Like "*利"
If strMK Like "亜久利" Then GenderEstimate = "男性": GoTo SKIPPOINT
If strMK Like "勝利" Then GenderEstimate = "男性": GoTo SKIPPOINT
If strMF Like "*り" Then GenderEstimate = "女性": GoTo SKIPPOINT
GenderEstimate = "男性"
'起 の判定
Case strMK Like "*起"
If strMF Like "ゆき" Then GenderEstimate = "女性": GoTo SKIPPOINT
GenderEstimate = "男性"
'康 の判定、こう ではじまれば男性
Case strMK Like "康*"
If strMF Like "こう*" Then GenderEstimate = "男性": GoTo SKIPPOINT
If strMF Like "やす??" Then GenderEstimate = "男性": GoTo SKIPPOINT
'咲 の判定、「実咲」「美咲」の場合のみ女性
Case strMK Like "*咲"
If strMK Like "[実美]咲" Then GenderEstimate = "女性": GoTo SKIPPOINT
'彬 の判定、「あき」「あきら」の場合のみ男性。中国人女性人名への誤り判定対策
Case strMK Like "*彬"
If strMF Like "*あき" Then GenderEstimate = "男性": GoTo SKIPPOINT
If strMF Like "*あきら" Then GenderEstimate = "男性": GoTo SKIPPOINT
'嘉 の判定、「よし」とはじまる、あるいは終わる名前のみ男性。か と読むときは女性
Case strMK Like "嘉*"
If strMF Like "よし*" Then GenderEstimate = "男性": GoTo SKIPPOINT
Case strMK Like "*嘉"
If strMF Like "*よし" Then GenderEstimate = "男性": GoTo SKIPPOINT
If strMF Like "*か" Then GenderEstimate = "女性": GoTo SKIPPOINT
'香 の判定。2文字名で香からはじまるときだけ女性。
'しずか などは亀井静香の例もあるので別の漢字へのマッチングに引っ掛ける。
Case strMK Like "香?"
GenderEstimate = "女性": GoTo SKIPPOINT
Case strMK Like "?香?"
GenderEstimate = "女性": GoTo SKIPPOINT
'哉 の判定。「かな」で読み終わる場合女性、「や」で読み終わる場合男性
Case strMK Like "*哉"
If strMF Like "*かな" Then GenderEstimate = "女性": GoTo SKIPPOINT
If strMF Like "*や" Then GenderEstimate = "男性": GoTo SKIPPOINT
If strMF Like "*ちか" Then GenderEstimate = "男性": GoTo SKIPPOINT
'飛 の判定、「飛鳥」の場合は言及を避ける。それ以外は男性
Case strMK Like "*飛*"
If strMK Like "飛鳥" Then GoTo SKIPPOINT
GenderEstimate = "男性"
'澄 の判定、「真澄」のみ女性の可能性も男性の可能性もあるので言及を避ける。
'2文字名の最終が「澄」の場合だけ男性
Case strMK Like "?澄"
If strMK Like "真澄" Then GoTo SKIPPOINT
GenderEstimate = "男性"
'希 の判定は逃げます。何かいい案あればどうぞ
'里 の判定、「さと」と読み終わるときだけ女性
Case strMK Like "?里"
If strMF Like "ばんり" Then GenderEstimate = "男性": GoTo SKIPPOINT
If strMF Like "[あま]さと" Then GenderEstimate = "男性": GoTo SKIPPOINT
If strMF Like "かいり" Then GenderEstimate = "男性": GoTo SKIPPOINT
If strMF Like "*さと" Then GenderEstimate = "女性": GoTo SKIPPOINT
If strMF Like "*り" Then GenderEstimate = "女性": GoTo SKIPPOINT
Case strMK Like "?理"
If strMF Like "[あま]さと" Then GenderEstimate = "男性": GoTo SKIPPOINT
If strMF Like "*[おえ]り" Then GenderEstimate = "女性": GoTo SKIPPOINT
'祐 の判定
Case strMK Like "*祐"
If strMF Like "*すけ" Then GenderEstimate = "男性": GoTo SKIPPOINT
If strMF Like "*ゆ" Then GenderEstimate = "女性": GoTo SKIPPOINT
Case strMK Like "祐*"
If strMF Like "ゆうき" Then GenderEstimate = "男性": GoTo SKIPPOINT
If strMF Like "ゆ?" Or strMF Like "ゆか?" Then GenderEstimate = "女性": GoTo SKIPPOINT
'佑 の判定
Case strMK Like "*佑"
If strMF Like "*すけ" Then GenderEstimate = "男性": GoTo SKIPPOINT
If strMF Like "*ゆ" Then GenderEstimate = "女性": GoTo SKIPPOINT
Case strMK Like "佑*"
If strMF Like "ゆうき" Then GenderEstimate = "男性": GoTo SKIPPOINT
If strMF Like "ゆ?" Or strMF Like "ゆか?" Then GenderEstimate = "女性": GoTo SKIPPOINT
'記 の判定
Case strMK Like "?記"
If strMF Like "[みさまゆ]き" Then GenderEstimate = "女性": GoTo SKIPPOINT
GenderEstimate = "男性"
'周 の判定
Case strMK Like "周*"
If strMF Like "あまね" Then GenderEstimate = "女性": GoTo SKIPPOINT
If strMF Like "ひろし" Then GenderEstimate = "男性": GoTo SKIPPOINT
If strMF Like "しゅう*" Then GenderEstimate = "男性": GoTo SKIPPOINT
'穂 の判定
Case strMK Like "*穂"
If strMF Like "みずほ" Then GoTo SKIPPOINT
GenderEstimate = "女性"
'慧 の判定
Case strMK Like "?慧"
If strMK Like "詩慧" Then GenderEstimate = "女性": GoTo SKIPPOINT
GenderEstimate = "男性": GoTo SKIPPOINT
'寿 の判定
Case strMK Like "*寿"
If strMF Like "*ひさ" Then GenderEstimate = "男性": GoTo SKIPPOINT
'英 の判定
Case strMK Like "英?"
If strMF Like "はな?" Then GenderEstimate = "女性": GoTo SKIPPOINT
If strMK Like "?[貴和尚和世紀]" Then GenderEstimate = "男性": GoTo SKIPPOINT
'好 の判定
Case strMK Like "?好"
If strMF Like "??よし" Then GenderEstimate = "男性": GoTo SKIPPOINT
'----------------------------------------------
'優先順位上、下でないとおかしくなるもの
'----------------------------------------------
'文 の判定その2、「ふみ」ではじまる読みを
Case strMK Like "文?"
If strMF Like "ふみ?" Then GenderEstimate = "女性": GoTo SKIPPOINT
If strMF Like "あや?" Then GenderEstimate = "女性": GoTo SKIPPOINT
'----------------------------------------------
'Level3:上記フィルタでもマッチングできなかったものは読みで判定を行います。
'----------------------------------------------
'1.まずそもそもエスケープしたい名前をここで全部弾いておきます
Case strMF Like "あすか"
GoTo SKIPPOINT
'男性2~3文字固定ネーム
Case strMF Like "けん" Or strMF Like "かい" Or _
strMF Like "たくみ" Or strMF Like "とおる" Or strMF Like "たかし" Or strMF Like "なおき" Or strMF Like "はるき" Or strMF Like "りょう" Or _
strMF Like "ひろき" Or strMF Like "ゆうほ" Or strMF Like "まさき" Or strMF Like "ともき" Or strMF Like "??はる" Or strMF Like "ふみや" Or _
strMF Like "たくま" Or strMF Like "たけし" Or strMF Like "こうき" Or strMF Like "げんき" Or strMF Like "ひろむ" Or strMF Like "まさと" Or _
strMF Like "じゅん" Or strMF Like "しゅん" Or strMF Like "さとし" Or strMF Like "こうき" Or strMF Like "わたる" Or strMF Like "たかお" Or _
strMF Like "ゆうや" Or strMF Like "りょう" Or strMF Like "ゆたか" Or strMF Like "しんや" Or strMF Like "いくお" Or strMF Like "よしき" Or _
strMF Like "??しげ" Or strMF Like "??たか" Or strMF Like "??なり" Or strMF Like "たくや" Or strMF Like "はじめ" Or strMF Like "もとき" Or _
strMF Like "みのる" Or strMF Like "みとむ" Or strMF Like "なるき" Or strMF Like "あつし" Or strMF Like "あゆむ" Or strMF Like "あきら"
GenderEstimate = "男性": GoTo SKIPPOINT
'男性4文字固定ネーム
Case strMF Like "まさひこ" Or strMF Like "まさひろ" Or strMF Like "まさたか" Or strMF Like "たかよし" Or strMF Like "たかはる" Or strMF Like "いっせい" Or _
strMF Like "たかのり" Or strMF Like "たかあき" Or strMF Like "なおすみ" Or strMF Like "なおずみ"
GenderEstimate = "男性": GoTo SKIPPOINT
'男性可変ネーム
Case strMF Like "[のかきけせ]んた" Or strMF Like "やす[おしき]" Or strMF Like "[あえかせたてなまみやり]つお" Or strMF Like "ゆ[ずづ]る" Or _
strMF Like "てつ[おや]" Or strMF Like "[まひ]さし" Or strMF Like "たけ[るしと]" Or strMF Like "[あいわ]たる" Or strMF Like "??の[りぶ]" Or _
strMF Like "とし*" Or strMF Like "かい*" Or strMF Like "かず*" Or strMF Like "かつ*" Or strMF Like "けん?" Or strMF Like "ひで*" Or strMF Like "*すけ" Or _
strMF Like "*かず" Or strMF Like "*だい*" Or strMF Like "*じ" Or strMF Like "??ひさ" Or strMF Like "??ちか" Or strMF Like "??ひろ" Or strMF Like "??が"
GenderEstimate = "男性": GoTo SKIPPOINT
'女性可変ネーム
Case strMF Like "*み" Or strMF Like "*ゆ" Or strMF Like "?さよ"
GenderEstimate = "女性": GoTo SKIPPOINT
'女性:2文字読みネーム
Case strMF Like "あ[いきみや]" Or strMF Like "い[くあよ]" Or strMF Like "え[まみり]" Or strMF Like "*[かさりず]え" Or strMF Like "[あいさしなりみか]お" Or _
strMF Like "[ゆちみるり]か" Or strMF Like "き[みきやゆほわ]" Or strMF Like "[みさま]き" Or strMF Like "く[なみ]" Or _
strMF Like "さ[やきや]" Or _
strMF Like "ち[ほ]" Or _
strMF Like "な[なみゆ]" Or strMF Like "*ね" Or strMF Like "[さちつなにはひふもゆらりるれまかみ]な" Or _
strMF Like "[かしなまちみ]ほ" Or strMF Like "ま[いほりきみ]" Or strMF Like "[ゆりたみ]ま" Or _
strMF Like "み[なゆかえさ]" Or strMF Like "めい" Or _
strMF Like "や[]" Or _
strMF Like "り[かなみほさよと]" Or strMF Like "[えゆき]り" Or _
strMF Like "わ[かみ]"
GenderEstimate = "女性": GoTo SKIPPOINT
'女性:3文字読みネーム「後1文字が動く」
Case strMF Like "あや[なかみめこ]" Or strMF Like "まり*" Or strMF Like "はる[なかこみ]" Or strMF Like "あき[なかこみ]" Or strMF Like "ふゆ[なかこみ]" Or _
strMF Like "るみ[なかこ]" Or strMF Like "えり[なかこ]" Or strMF Like "ゆり[なかこ]" Or strMF Like "さと[こみ]" Or strMF Like "さや[かこ]" Or strMF Like "さよこ" Or _
strMF Like "あきほ" Or strMF Like "あ[すずや][なみさ]" Or strMF Like "い[づず]み" Or strMF Like "のり[かこ]" Or strMF Like "[かなしみ]おり" Or strMF Like "かんな" Or _
strMF Like "[いさ]つき" Or strMF Like "さく[このみやら]" Or strMF Like "まどか" Or strMF Like "み[どのく]り" Or strMF Like "さえ[こか]" Or strMF Like "さやか" Or strMF Like "さゆり" Or _
strMF Like "すみれ" Or strMF Like "みどり" Or strMF Like "ゆい" Or strMF Like "あかり" Or strMF Like "わか[なこみ]" Or strMF Like "[あきちみり]さき" Or strMF Like "かすみ" Or _
strMF Like "[あうえきくなのま]みか" Or strMF Like "[あうえきくなのま]みな" Or strMF Like "ゆうこ" Or strMF Like "あさひ" Or strMF Like "さえら" Or strMF Like "[さしみ]おり" Or _
strMF Like "やすか" Or strMF Like "とも[かえよ]"
GenderEstimate = "女性": GoTo SKIPPOINT
'女性:3文字読みネーム「前1文字が動く」
Case strMF Like "みさ[ときえこよ]" Or strMF Like "[みち]さと" Or strMF Like "いのり" Or strMF Like "かえで" Or strMF Like "ゆかり"
GenderEstimate = "女性": GoTo SKIPPOINT
'読みで難しいもの
Case strMF Like "ゆき*"
If strMF Like "*や" Then GenderEstimate = "男性": GoTo SKIPPOINT
If strMF Like "*[こえか]" Then GenderEstimate = "女性": GoTo SKIPPOINT
If strMF Like "ゆき" Then GenderEstimate = "女性": GoTo SKIPPOINT
GenderEstimate = "男性": GoTo SKIPPOINT
End Select
SKIPPOINT:
'----------------------------------------------
'Level4:実験時に、この時点であぶれたのは全体の7%前後。最終振り分け処理です。
'----------------------------------------------
If GenderEstimate = "" Then
Select Case True
Case strMF Like "まさ??"
GenderEstimate = "男性": GoTo SKIPPOINT2
Case strMF Like "まさ?"
If strMF Like "??[やおきる]" Then GenderEstimate = "男性": GoTo SKIPPOINT2
End Select
End If
SKIPPOINT2:
End Function
@lunark

This comment has been minimized.

Copy link
Owner Author

commented Dec 20, 2012

開発ポリシー

このマクロは、一応出来ねーなりになんとかしてみようぜ、というコンセプトで作っています。

なお、本マクロの変換性能は、下記の通り、実験に使っている名簿では優れています。が、これはカタログスペックとお考え下さい。
私がこのマクロを作った本懐は別の所にあります。

本マクロの存在目的・及び開発者の開発目的は、名簿の性別抜けの解決です。
歯抜けでは我が心が千々に乱れるではないか!

というわけで、本マクロの仕組みですが、文字の読みや漢字の配列パターン、時には例外事項として名前そのものを
比較演算子を用いて比較し、性別を高精度に割り出すことを試みています。

Gistですので、好きにforkして下さい。

また、実業務の際には、補助的に用いることをおすすめします。
間違っても、既に記録された名簿に上書き処理することのないようお気をつけ下さい。

変換性能について

手元で実業務に用いている名簿から名前と名前ふりがなだけを抜き出したものを用い、デバッグしています。
8428件の名簿中、7903件が変換(93.771%)され、7882件が成功(99.734%)しています(Revision: 10

引数一覧

GenderEstimate(strMK As String, Optional strMF As String)
第1引数:名(漢字) …英語は自動的に無視しますが、中国語は一部反応してしまいます
第2引数:名(ふりがな) …カタカナも可
返り値:性別("男性" or "女性")

更新履歴

Revision: 10 とりあえず実用レベルに達したと判断。
Revision: 6 性能向上・エンバグ直し
Revision: 2 コードを整序しました。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.