Skip to content

Commit

Permalink
add kp, k, m, t, u and v sources
Browse files Browse the repository at this point in the history
  • Loading branch information
tony committed May 26, 2017
1 parent beaaa53 commit f575da1
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/fixtures/Unihan_IRGSources.txt
Original file line number Diff line number Diff line change
Expand Up @@ -502,5 +502,10 @@ U+3492 kIRG_TSource T3-4B26
U+4336 kRSUnicode 120'.3
U+4E00 kIRG_HSource HB1-A440
U+4E07 kIRG_HSource HB2-C945
U+3ED0 kIRG_KPSource KP0-EAB2
U+4E06 kIRG_KSource K2-2121
U+21290 kIRG_MSource MAC-00077
U+22016 kIRG_USource UTC-00069
U+221EC kIRG_USource UCI-00937

# EOF
64 changes: 64 additions & 0 deletions tests/test_expansion.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,3 +692,67 @@ def test_expand_kIRG_JSource(expanded_data, ucn, fieldval, expected):
assert item['kIRG_JSource'] == expected

assert expansion.expand_field('kIRG_JSource', fieldval) == expected


@pytest.mark.parametrize("field,ucn,fieldval,expected", [
# U+3ED0 kIRG_KPSource KP0-EAB2
("kIRG_KPSource", "U+3ED0", "KP0-EAB2", {
"source": "KP0",
"location": "EAB2"
}),
# U+340C kIRG_KPSource KP1-3451
("kIRG_KPSource", "U+340C", "KP1-3451", {
"source": "KP1",
"location": "3451"
}),
# U+4E06 kIRG_KSource K2-2121
("kIRG_KSource", "U+4E06", "K2-2121", {
"source": "K2",
"location": "2121"
}),
# U+3401 kIRG_KSource K3-2121
("kIRG_KSource", "U+3401", "K3-2121", {
"source": "K3",
"location": "2121"
}),
# U+21290 kIRG_MSource MAC-00077
("kIRG_MSource", "U+21290", "MAC-00077", {
"source": "MAC",
"location": "00077"
}),
# U+3400 kIRG_TSource T6-222C
("kIRG_TSource", "U+3400", "T6-222C", {
"source": "T6",
"location": "222C"
}),
# U+3401 kIRG_TSource T4-2224
("kIRG_TSource", "U+3401", "T4-2224", {
"source": "T4",
"location": "2224"
}),
# U+22016 kIRG_USource UTC-00069
("kIRG_USource", "U+22016", "UTC-00069", {
"source": "UTC",
"location": "00069"
}),
# U+221EC kIRG_USource UCI-00937
("kIRG_USource", "U+221EC", "UCI-00937", {
"source": "UCI",
"location": "00937"
}),
# U+346B kIRG_VSource V0-3034
("kIRG_VSource", "U+346B", "V0-3034", {
"source": "V0",
"location": "3034"
}),
# U+340C kIRG_VSource V2-8874
("kIRG_VSource", "U+340C", "V2-8874", {
"source": "V2",
"location": "8874"
}),
])
def test_expand_kIRG_KPSource(expanded_data, field, ucn, fieldval, expected):
item = [i for i in expanded_data if i['ucn'] == ucn][0]
assert item[field] == expected

assert expansion.expand_field(field, fieldval) == expected
6 changes: 6 additions & 0 deletions unihan_tabular/expansion.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,12 @@ def _expand_kIRG_GenericSource(value):
expand_kIRG_GSource = _expand_kIRG_GenericSource
expand_kIRG_HSource = _expand_kIRG_GenericSource
expand_kIRG_JSource = _expand_kIRG_GenericSource
expand_kIRG_KPSource = _expand_kIRG_GenericSource
expand_kIRG_KSource = _expand_kIRG_GenericSource
expand_kIRG_MSource = _expand_kIRG_GenericSource
expand_kIRG_TSource = _expand_kIRG_GenericSource
expand_kIRG_USource = _expand_kIRG_GenericSource
expand_kIRG_VSource = _expand_kIRG_GenericSource


def expand_field(field, fvalue):
Expand Down

0 comments on commit f575da1

Please sign in to comment.