Module:Hangul
Jump to navigation
Jump to search
Usage
Final Medial
|
ㄱ | ㄲ | ㄳ | ㄴ | ㄵ | ㄶ | ㄷ | ㄹ | ㄺ | ㄻ | ㄼ | ㄽ | ㄾ | ㄿ | ㅀ | ㅁ | ㅂ | ㅄ | ㅅ | ㅆ | ㅇ | ㅈ | ㅊ | ㅋ | ㅌ | ㅍ | ㅎ | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ㅏ | 가 | 각 | 갂 | 갃 | 간 | 갅 | 갆 | 갇 | 갈 | 갉 | 갊 | 갋 | 갌 | 갍 | 갎 | 갏 | 감 | 갑 | 값 | 갓 | 갔 | 강 | 갖 | 갗 | 갘 | 같 | 갚 | 갛 |
ㅐ | 개 | 객 | 갞 | 갟 | 갠 | 갡 | 갢 | 갣 | 갤 | 갥 | 갦 | 갧 | 갨 | 갩 | 갪 | 갫 | 갬 | 갭 | 갮 | 갯 | 갰 | 갱 | 갲 | 갳 | 갴 | 갵 | 갶 | 갷 |
ㅑ | 갸 | 갹 | 갺 | 갻 | 갼 | 갽 | 갾 | 갿 | 걀 | 걁 | 걂 | 걃 | 걄 | 걅 | 걆 | 걇 | 걈 | 걉 | 걊 | 걋 | 걌 | 걍 | 걎 | 걏 | 걐 | 걑 | 걒 | 걓 |
ㅒ | 걔 | 걕 | 걖 | 걗 | 걘 | 걙 | 걚 | 걛 | 걜 | 걝 | 걞 | 걟 | 걠 | 걡 | 걢 | 걣 | 걤 | 걥 | 걦 | 걧 | 걨 | 걩 | 걪 | 걫 | 걬 | 걭 | 걮 | 걯 |
ㅓ | 거 | 걱 | 걲 | 걳 | 건 | 걵 | 걶 | 걷 | 걸 | 걹 | 걺 | 걻 | 걼 | 걽 | 걾 | 걿 | 검 | 겁 | 겂 | 것 | 겄 | 겅 | 겆 | 겇 | 겈 | 겉 | 겊 | 겋 |
ㅔ | 게 | 겍 | 겎 | 겏 | 겐 | 겑 | 겒 | 겓 | 겔 | 겕 | 겖 | 겗 | 겘 | 겙 | 겚 | 겛 | 겜 | 겝 | 겞 | 겟 | 겠 | 겡 | 겢 | 겣 | 겤 | 겥 | 겦 | 겧 |
ㅕ | 겨 | 격 | 겪 | 겫 | 견 | 겭 | 겮 | 겯 | 결 | 겱 | 겲 | 겳 | 겴 | 겵 | 겶 | 겷 | 겸 | 겹 | 겺 | 겻 | 겼 | 경 | 겾 | 겿 | 곀 | 곁 | 곂 | 곃 |
ㅖ | 계 | 곅 | 곆 | 곇 | 곈 | 곉 | 곊 | 곋 | 곌 | 곍 | 곎 | 곏 | 곐 | 곑 | 곒 | 곓 | 곔 | 곕 | 곖 | 곗 | 곘 | 곙 | 곚 | 곛 | 곜 | 곝 | 곞 | 곟 |
ㅗ | 고 | 곡 | 곢 | 곣 | 곤 | 곥 | 곦 | 곧 | 골 | 곩 | 곪 | 곫 | 곬 | 곭 | 곮 | 곯 | 곰 | 곱 | 곲 | 곳 | 곴 | 공 | 곶 | 곷 | 곸 | 곹 | 곺 | 곻 |
ㅘ | 과 | 곽 | 곾 | 곿 | 관 | 괁 | 괂 | 괃 | 괄 | 괅 | 괆 | 괇 | 괈 | 괉 | 괊 | 괋 | 괌 | 괍 | 괎 | 괏 | 괐 | 광 | 괒 | 괓 | 괔 | 괕 | 괖 | 괗 |
ㅙ | 괘 | 괙 | 괚 | 괛 | 괜 | 괝 | 괞 | 괟 | 괠 | 괡 | 괢 | 괣 | 괤 | 괥 | 괦 | 괧 | 괨 | 괩 | 괪 | 괫 | 괬 | 괭 | 괮 | 괯 | 괰 | 괱 | 괲 | 괳 |
ㅚ | 괴 | 괵 | 괶 | 괷 | 괸 | 괹 | 괺 | 괻 | 괼 | 괽 | 괾 | 괿 | 굀 | 굁 | 굂 | 굃 | 굄 | 굅 | 굆 | 굇 | 굈 | 굉 | 굊 | 굋 | 굌 | 굍 | 굎 | 굏 |
ㅛ | 교 | 굑 | 굒 | 굓 | 굔 | 굕 | 굖 | 굗 | 굘 | 굙 | 굚 | 굛 | 굜 | 굝 | 굞 | 굟 | 굠 | 굡 | 굢 | 굣 | 굤 | 굥 | 굦 | 굧 | 굨 | 굩 | 굪 | 굫 |
ㅜ | 구 | 국 | 굮 | 굯 | 군 | 굱 | 굲 | 굳 | 굴 | 굵 | 굶 | 굷 | 굸 | 굹 | 굺 | 굻 | 굼 | 굽 | 굾 | 굿 | 궀 | 궁 | 궂 | 궃 | 궄 | 궅 | 궆 | 궇 |
ㅝ | 궈 | 궉 | 궊 | 궋 | 권 | 궍 | 궎 | 궏 | 궐 | 궑 | 궒 | 궓 | 궔 | 궕 | 궖 | 궗 | 궘 | 궙 | 궚 | 궛 | 궜 | 궝 | 궞 | 궟 | 궠 | 궡 | 궢 | 궣 |
ㅞ | 궤 | 궥 | 궦 | 궧 | 궨 | 궩 | 궪 | 궫 | 궬 | 궭 | 궮 | 궯 | 궰 | 궱 | 궲 | 궳 | 궴 | 궵 | 궶 | 궷 | 궸 | 궹 | 궺 | 궻 | 궼 | 궽 | 궾 | 궿 |
ㅟ | 귀 | 귁 | 귂 | 귃 | 귄 | 귅 | 귆 | 귇 | 귈 | 귉 | 귊 | 귋 | 귌 | 귍 | 귎 | 귏 | 귐 | 귑 | 귒 | 귓 | 귔 | 귕 | 귖 | 귗 | 귘 | 귙 | 귚 | 귛 |
ㅠ | 규 | 귝 | 귞 | 귟 | 균 | 귡 | 귢 | 귣 | 귤 | 귥 | 귦 | 귧 | 귨 | 귩 | 귪 | 귫 | 귬 | 귭 | 귮 | 귯 | 귰 | 귱 | 귲 | 귳 | 귴 | 귵 | 귶 | 귷 |
ㅡ | 그 | 극 | 귺 | 귻 | 근 | 귽 | 귾 | 귿 | 글 | 긁 | 긂 | 긃 | 긄 | 긅 | 긆 | 긇 | 금 | 급 | 긊 | 긋 | 긌 | 긍 | 긎 | 긏 | 긐 | 긑 | 긒 | 긓 |
ㅢ | 긔 | 긕 | 긖 | 긗 | 긘 | 긙 | 긚 | 긛 | 긜 | 긝 | 긞 | 긟 | 긠 | 긡 | 긢 | 긣 | 긤 | 긥 | 긦 | 긧 | 긨 | 긩 | 긪 | 긫 | 긬 | 긭 | 긮 | 긯 |
ㅣ | 기 | 긱 | 긲 | 긳 | 긴 | 긵 | 긶 | 긷 | 길 | 긹 | 긺 | 긻 | 긼 | 긽 | 긾 | 긿 | 김 | 깁 | 깂 | 깃 | 깄 | 깅 | 깆 | 깇 | 깈 | 깉 | 깊 | 깋 |
ㄱ | ㄲ | ㄴ | ㄷ | ㄸ | ㄹ | ㅁ | ㅂ | ㅃ | ㅅ | ㅆ | ㅇ | ㅈ | ㅉ | ㅊ | ㅋ | ㅌ | ㅍ | ㅎ |
local p = {}
local data = require 'Module:Hangul/data'
---- From [[wikt:Module:ko-hangul]
-- Given the "syllable index" of a precomposed Hangul syllable (see
-- above), returns "indices" representing the three constituent jamo
-- ("lead", i.e. initial consonant; "vowel"; and "tail", i.e. final
-- consonant, except that zero denotes the absence of a final consonant).
local function syllableIndex2JamoIndices(syllableIndex)
local lIndex = math.floor(syllableIndex / 588)
local vIndex = math.floor((syllableIndex % 588) / 28)
local tIndex = syllableIndex % 28
return lIndex, vIndex, tIndex
end
----
local tocodepoint = mw.ustring.codepoint
local function indexof(arr, val)
for i, v in ipairs(arr) do
if v == val then
return i
end
end
return -1
end
local function get_name(char)
local codepoint = tocodepoint(char)
-- Hangul Compatibility Jamo block
if 0x3130 <= codepoint and codepoint <= 0x318F then
return ('U+%X: HANGUL LETTER %s'):format(codepoint, data.names[codepoint - 0x3130])
-- Hangul Syllables block
-- From [[wikt:Module:Unicode data]].
-- Cheaper to derive names from decomposed form of syllable?
elseif 0xAC00 <= codepoint and codepoint <= 0xD7A3 then
local li, vi, ti = syllableIndex2JamoIndices(codepoint - 0xAC00)
return ("U+%X: HANGUL SYLLABLE %s%s%s"):format(
codepoint, data.leads[li], data.vowels[vi], data.trails[ti])
else
error(('No name for U+%X found.'):format(codepoint))
end
end
local function get_anchor(index)
return string.char(('a'):byte() + index - 1):rep(2)
end
local function diag_split_header(column_text, row_text)
return mw.getCurrentFrame():expandTemplate{
title = 'diagonal_split_header',
args = { column_text, row_text },
}
end
local function syllables_by_initial(initial)
local codepoint = mw.ustring.codepoint(initial)
if not (0x1100 <= codepoint and codepoint <= 0x1112) then
error('Incorrect initial ' .. initial .. '. Should be between U+1100 and U+1112.')
end
local initial_index = indexof(data.initials, initial)
local output = {}
local i = 0
local function push(text)
i = i + 1
output[i] = text
end
push(
([[
{| class="wikitable collapsible collapsed nowrap"
|+ id="%s" | Initial <span lang="ko">%s</span>
|-
! %s]]):format(
get_anchor(initial_index),
data.independent_initials[initial_index],
diag_split_header('Medial', 'Final'))) -- initial jamo
for _, final in ipairs(data.independent_finals) do
push(('! title="%s" | <span lang="ko">%s</span>')
:format(final ~= '' and get_name(final) or '', final))
end
for i, medial in ipairs(data.medials) do
push('|- lang="ko"')
local independent_medial = data.independent_medials[i]
push(('! scope="row" title="%s" | %s')
:format(get_name(independent_medial), independent_medial))
for _, final in ipairs(data.finals) do
push(('| %s%s%s'):format(initial, medial, final))
end
end
push('|}')
output = table.concat(output, '\n')
output = mw.ustring.toNFC(output)
output = mw.ustring.gsub( -- Add names of syllable codepoints.
output,
'[가-힣]', -- [[Hangul Syllables]] block (U+AC00-D7AF)
function (syllable)
return ('title="%s" | %s'):format(get_name(syllable), syllable)
end)
-- Check for consecutive span tags.
-- output:gsub('<span[^>]+>[^<]*</span><span[^>]+>[^<]*</span>', mw.log)
return output
end
function p.syllables_by_initial(frame)
local initial = frame.args[1] or 'ᄀ'
return syllables_by_initial(initial)
end
function p.all_syllables(frame)
local tables = {}
for i, initial in ipairs(data.initials) do
tables[i] = syllables_by_initial(initial)
end
return table.concat(tables, '\n')
end
function p.TOC(frame)
local output = {}
for i, initial in ipairs(data.independent_initials) do
table.insert(output, ('| [[#%s|%s]]'):format(get_anchor(i), initial))
end
table.insert(output, 1, '{| class="wikitable" lang="ko" style="width: 96px; height: 10px;"')
table.insert(output, '|}')
return table.concat(output, '\n')
end
return p