Module:ko-dial-syn
Jump to navigation
Jump to search
- The following documentation is located at Module:ko-dial-syn/documentation. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
Korean dialectal synonyms module. See {{ko-dial}}
.
local export = {}
local m_links = require("Module:links")
local m_languages = require("Module:languages")
local m_ko_translit = require("Module:ko-translit")
local ko, okm, oko = m_languages.getByCode("ko"), m_languages.getByCode("okm"), m_languages.getByCode("oko")
local match = mw.ustring.match
local group_list = { "Standardised", "Historical", "Central", "Southeastern", "Southwestern", "Northwestern", "Northeastern", "Yukjin", "Jeju" }
local subgroup_list = {
["Central"] = { "Gyeonggi", "Yeongseo", "Yeongdong", "North Chungcheong", "South Chungcheong", "South Hwanghae", "North Hwanghae" },
["Southeastern"] = { "North Gyeongsang", "South Gyeongsang", "Diaspora" },
["Southwestern"] = { "North Jeolla", "South Jeolla" },
["Northwestern"] = { "South Pyongan", "North Pyongan", "Diaspora" },
["Northeastern"] = { "South Hamgyong", "North Hamgyong", "Diaspora" },
["Yukjin"] = { "Yukjin", "Diaspora" },
}
local group_qualities = {
["Standardised"] = { colour = "", class = 1, count = 0, display = "Standardised forms" },
["Historical"] = { colour = "F5FFFA", class = 1, count = 0, display = "Historical forms" },
["Central"] = { colour = "FAF5F0", class = 2, count = 0, display = "Central" },
["Southeastern"] = { colour = "F7FAF0", class = 2, count = 0, display = "Southeastern<br>(Gyeongsang)" },
["Southwestern"] = { colour = "FAF0F6", class = 2, count = 0, display = "Southwestern<br>(Jeolla)" },
["Northwestern"] = { colour = "F4F0FA", class = 2, count = 0, display = "Northwestern<br>(Pyongan)" },
["Northeastern"] = { colour = "E6F7FF", class = 2, count = 0, display = "Northeastern<br>(Hamgyong)" },
["Yukjin"] = { colour = "F5F8FF", class = 2, count = 0, display = "Yukjin" },
["Jeju"] = { colour = "FFFFF5", class = 3, count = 0, display = "Jeju" },
}
local subgroup_colours = {
["Central-Gyeonggi"] = "FAF5F0",
["Central-Yeongseo"] = "F0F5FA",
["Central-Yeongdong"] = "F0FAF3",
["Central-North Chungcheong"] = "FAF0F6",
["Central-South Chungcheong"] = "FAF9F0",
["Central-South Hwanghae"] = "F0F5FA",
["Central-North Hwanghae"] = "F4F0FA",
["Southeastern-North Gyeongsang"] = "F7FAF0",
["Southeastern-South Gyeongsang"] = "F0F5FA",
["Southeastern-Diaspora"] = "ececec",
["Southwestern-North Jeolla"] = "FAF0F6",
["Southwestern-South Jeolla"] = "F0FAF3",
["Northwestern-South Pyongan"] = "F4F0FA",
["Northwestern-North Pyongan"] = "FAF5F0",
["Northwestern-Diaspora"] = "ececec",
["Northeastern-South Hamgyong"] = "E6F7FF",
["Northeastern-North Hamgyong"] = "F7F5FF",
["Northeastern-Diaspora"] = "ececec",
["Yukjin-Yukjin"] = "F5F8FF",
["Yukjin-Diaspora"] = "ececec",
}
function export.main(frame)
local args = frame:getParent().args
local pagename = mw.title.getCurrentTitle().text
local target_page = args[1] or pagename
local resource_page = "Module:ko/data/dial-syn/" .. target_page
local variety_data = require("Module:ko/data/dial")
local m_syndata
local record_exists = {}
if mw.title.new(resource_page).exists then
m_syndata = require(resource_page)
else
return frame:expandTemplate{ title = "Template:ko-dial/uncreated", args = { target_page } }
end
local template = {
["Standardised"] = {},
["Historical"] = {},
["Central"] = {
["Gyeonggi"] = {},
["Yeongseo"] = {},
["Yeongdong"] = {},
["North Chungcheong"] = {},
["South Chungcheong"] = {},
["South Hwanghae"] = {},
["North Hwanghae"] = {},
},
["Southeastern"] = {
["North Gyeongsang"] = {},
["South Gyeongsang"] = {},
["Diaspora"] = {},
},
["Southwestern"] = {
["North Jeolla"] = {},
["South Jeolla"] = {},
},
["Northwestern"] = {
["South Pyongan"] = {},
["North Pyongan"] = {},
["Diaspora"] = {},
},
["Northeastern"] = {
["South Hamgyong"] = {},
["North Hamgyong"] = {},
["Diaspora"] = {},
},
["Yukjin"] = {
["Yukjin"] = {},
["Diaspora"] = {},
},
["Jeju"] = {},
}
local main_title = m_links.full_link( { term = target_page, lang = ko, gloss = m_syndata.gloss } )
local synonym_table = { [=[{| class="mw-collapsible mw-collapsed wikitable"
|-
! colspan="4" | Dialectal synonyms of ]=] .. main_title .. " [[Template:ko-dial-map/" .. target_page .. '|<small>[map]</small>]]\n' .. [=[
|-
! style="background:#E8ECFA" | Dialect group
! style="background:#E8ECFA" | Region
! style="background:#E8ECFA" | Location
! style="background:#E8ECFA" | Words]=] .. [=[
<div style="float: right; clear: right; font-size:60%"><span class="plainlinks">[]=] ..
tostring(mw.uri.fullUrl("Module:ko/data/dial-syn/" .. target_page, { ["action"] = "edit" })) ..
' edit]</span></div>' }
if m_syndata.note then table_note = m_syndata.note end
for location, synonym_set in pairs(m_syndata.syns) do
if synonym_set[1] ~= "" then
local formatted_synonyms = {}
for i, synonym in ipairs(synonym_set) do
if location == "Old Korean" then
table.insert(formatted_synonyms, synonym)
elseif location == "Old Korean-JLLS" then
local synonym_tr = match(synonym, "/(.+)")
local synonym = mw.ustring.gsub(synonym, "/.+", "")
table.insert(formatted_synonyms,
m_links.full_link( { term = synonym, tr = '<span class="IPA">' .. synonym_tr .. '</span>', sc = Hani, lang = oko } ))
else
local synonym_tr = match(synonym, "/([^/:]+)")
local synonym = mw.ustring.gsub(synonym, "/[^/:]+", "")
local synonym_note = mw.text.split(synonym, ":")
local synonym_etym = mw.text.split(synonym_note[1], "_")
local syn, etym, note = synonym_etym[1], synonym_etym[2], synonym_note[2]
if (match(variety_data[location].group, "eastern") or variety_data[location].group == "Yukjin" or location == "Donghae" or location == "Samcheok" or location == "Taebaek" or location == "Yeongwol" or location == "Gangneung") and not synonym_tr then
syn = mw.ustring.gsub(syn, "\'(.)", "%1".."́")
syn = mw.ustring.gsub(syn, "([^́])([^́])", "%1".."̀".."%2")
syn = mw.ustring.gsub(syn, "([^́])$", "%1̀")
synonym_tr = m_ko_translit.tr(syn)
synonym_tr = mw.ustring.gsub(synonym_tr, "([aeiou])([aeiou])([̀́])", "%1%3%2")
syn = mw.ustring.gsub(syn, "[́̀]", "")
end
--if location == "Middle Korean" then
-- synonym_tr = require("Module:okm-translit").tr(syn)
--end
local synonym_link = m_links.full_link( {
term = syn .. (etym and string.format("#Etymology %s", etym) or ""),
alt = etym and (syn .. string.format("<sub>%s</sub>", etym)),
tr = synonym_tr,
lang = (location == "Middle Korean" and okm or ko)
} )
note = note and ' <span style="font-size:80%"><i>' .. note .. '</i></span>' or ""
table.insert(formatted_synonyms, synonym_link .. note)
end
end
local location_data = variety_data[location] or error("No data for the location " .. location .. "!")
local location_link = location_data.link or location
local location_group = location_data.group
local location_region = location_data.region or nil
table.insert(
group_qualities[location_group].class ~= 2
and template[location_group]
or template[location_group][location_region],
{ location_data.order, location_link, formatted_synonyms })
group_qualities[location_group].count = group_qualities[location_group].count + 1
end
end
for _, group in ipairs(group_list) do
local qualities = group_qualities[group]
if qualities.count > 0 then
if qualities.class == 1 then
table.sort(template[group], function(first, second) return first[1] < second[1] end)
for index, point_data in ipairs(template[group]) do
table.insert(synonym_table, "\n|-")
if index == 1 then
table.insert(synonym_table, "\n| rowspan=" .. qualities.count ..
' style="background:#' .. qualities.colour .. "\" | '''" .. qualities.display .. "'''")
end
table.insert(synonym_table, "\n| colspan=\"2\" | '''" .. point_data[2] ..
"'''\n|" .. table.concat(point_data[3], ", "))
end
elseif qualities.class == 2 then
table.insert(synonym_table, '\n|-\n| rowspan=' .. qualities.count ..
' style="background:#' .. qualities.colour .. "\" | '''" .. qualities.display .. "'''")
local row_index = 0
for _, subgroup in pairs(subgroup_list[group]) do
table.sort(template[group][subgroup], function(first, second) return first[1] < second[1] end)
for index, point_data in ipairs(template[group][subgroup]) do
row_index = row_index + 1
if row_index > 1 then
table.insert(synonym_table, '\n|-')
end
if index == 1 then
table.insert(synonym_table, '\n| style="background:#' ..
subgroup_colours[group.."-"..subgroup] .. '" rowspan=' ..
#template[group][subgroup] .. " | '''" .. subgroup .. "'''")
end
table.insert(synonym_table, '\n| style="background:#' .. subgroup_colours[group.."-"..subgroup] .. '" | ' ..
point_data[2] .. '\n|' .. table.concat(point_data[3], ", "))
end
end
else
table.sort(template[group], function(first, second) return first[1] < second[1] end)
for index, point_data in ipairs(template[group]) do
table.insert(synonym_table, "\n|-")
if index == 1 then
table.insert(synonym_table, "\n| colspan=2 rowspan=" .. qualities.count ..
' style="background:#' .. qualities.colour .. "\" | '''" .. qualities.display .. "'''")
end
table.insert(synonym_table, "\n| " .. point_data[2] ..
"\n|" .. table.concat(point_data[3], ", "))
end
end
end
end
table.insert(synonym_table, '\n|-\n| colspan="4"; style="background:#ececec" | ' ..
"<small>" .. (table_note and table_note .. "<br>" or "") ..
"''This table is an amalgamation of surveys of speakers mostly born before 1950 and may not reflect the language of younger speakers, which has lexically converged towards the standard Seoul dialect in both North and South Koreas.''</small>")
table.insert(synonym_table, '\n|}')
return table.concat(synonym_table, "")
end
return export