Module:User:AG202/jje-pron

local export = {} local m_jje_utilities = require("Module:jje") local m_data = mw.loadData("Module:jje-pron/data")

local gsub = mw.ustring.gsub local match = mw.ustring.match local sub = mw.ustring.sub local char = mw.ustring.char local codepoint = mw.ustring.codepoint

local function tidy_phonetic(original, romanised) local ori_index, rom_index, result = 1, 1, {} for i = 1, mw.ustring.len(romanised) do		local romanised_syllable = mw.ustring.sub(romanised, rom_index, rom_index) local original_syllable = mw.ustring.sub(original, ori_index, ori_index) if romanised_syllable ~= original_syllable then -- Handle cases of non-precomposed choseong character changing if match(romanised_syllable, "[ᄀ-ᄒ]") then -- Insert choseong table.insert(result, ..romanised_syllable..) -- Insert jungseong romanised_syllable = mw.ustring.sub(romanised, rom_index + 1, rom_index + 1) table.insert(result, ..romanised_syllable..) -- Check if next character is jongseong; if so, insert, if not end iteration -- and continue accoringly romanised_syllable = mw.ustring.sub(romanised, rom_index + 2, rom_index + 2) if match(romanised_syllable, "ᆨ-ᇝ") then table.insert(w, ..romanised_syllable..) ori_index, rom_index = ori_index + 2, rom_index + 2 if match(original_syllable, "[^ ]") then rom_index = rom_index + 1 end if match(romanised_syllable, "[^ ]") then ori_index = ori_index + 1 end else ori_index, rom_index = ori_index + 1, rom_index + 1 if match(original_syllable, "[^ ]") then rom_index = rom_index + 1 end if match(romanised_syllable, "[^ ]") then ori_index = ori_index + 1 end end -- Handle cases of non-precomposed jongseong character changing elseif match(romanised_syllable, "[ᆨ-ᇝ]") then -- Remove previous non-bold choseong & jungseong table.remove(result, #result - 1) table.remove(result, #result) -- Insert choseong character romanised_syllable_cho = mw.ustring.sub(romanised, rom_index - 2, rom_index - 2) table.insert(result, ..romanised_syllable_cho..) -- Insert jungseong character romanised_syllable_jung = mw.ustring.sub(romanised, rom_index - 1, rom_index - 1) table.insert(result, ..romanised_syllable_jung..) -- Insert jongseong character table.insert(result, ..romanised_syllable..) if match(original_syllable, "[^ ]") then rom_index = rom_index + 1 end if match(romanised_syllable, "[^ ]") then ori_index = ori_index + 1 end -- Handle precomposed characters per typical method else table.insert(result, ..romanised_syllable..) if match(original_syllable, "[^ ]") then rom_index = rom_index + 1 end if match(romanised_syllable, "[^ ]") then ori_index = ori_index + 1 end end else table.insert(result, ' '..romanised_syllable..' ') ori_index, rom_index = ori_index + 1, rom_index + 1 end end return table.concat(result) end

function export.make(frame, scheme) return tidy_phonetic("ᄀᆞᇀ다 닷ᄀᆞ", "ᄀᆞᆮ따 닫ᄁᆞ") end

return export