Module:okm-sortkey

Hello, you have come here looking for the meaning of the word Module:okm-sortkey. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:okm-sortkey, but we will also tell you about its etymology, its characteristics and you will know how to say Module:okm-sortkey in singular and plural. Everything you need to know about the word Module:okm-sortkey you have here. The definition of the word Module:okm-sortkey will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:okm-sortkey, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.


local export = {}

local us = mw.ustring
local prefix = ""
local suffix = us.char(0x3130)

function G(s)
	return prefix .. s .. suffix
end

local initial_consonants = {
	 = G("ㄱ"),
	 = G("ㄱㄱ"),
	 = G("ㄴ"),
	 = G("ㄴㄴ"),
	 = G("ㄷ"),
	 = G("ㄷㄷ"),
	 = G("ㄹ"),
	 = G("ㅁ"),
	 = G("ㅂ"),
	 = G("ㅂㄱ"),
	 = G("ㅂㄷ"),
	 = G("ㅂㅂ"),
	 = G("ㅂㅅ"),
	 = G("ㅂㅅㄱ"),
	 = G("ㅂㅅㄷ"),
	 = G("ㅂㅅㅈ"),
	 = G("ㅂㅈ"),
	 = G("ㅂㅌ"),
	 = G("ㅂㅎ"), -- hack
	 = G("ㅅ"),
	 = G("ㅅㄱ"),
	 = G("ㅅㄴ"),
	 = G("ㅅㄷ"),
	 = G("ㅅㅁ"),
	 = G("ㅅㅂ"),
	 = G("ㅅㅂㄱ"),
	 = G("ㅅㅅ"),
	 = G("ㅅㅋ"),
	 = G("ㅅㅌ"),
	 = G("ㅅㅍ"),
	 = G("ㅅㅎ"), -- hack
	 = G("ㅇ"),
	 = G("ㅇㅇ"),
	 = G("ㅇㅎ"), -- hack
	 = G("ㅈ"),
	 = G("ㅈㅈ"),
	 = G("ㅊ"),
	 = G("ㅋ"),
	 = G("ㅌ"),
	 = G("ㅍ"),
	 = G("ㅎ"),
	 = G("ㅎㅎ"),
	 = G("ㆆ"),
}

local medials = {
	 = G("ㅏ"),
	 = G("ㅐ"),
	 = G("ㅑ"),
	 = G("ㅒ"),
	 = G("ㅓ"),
	 = G("ㅔ"),
	 = G("ㅕ"),
	 = G("ㅖ"),
	 = G("ㅗ"),
	 = G("ㅗㅏ"),
	 = G("ㅗㅐ"),
	 = G("ㅗㅣ"),
	 = G("ㅛ"),
	 = G("ㅛㅑ"),
	 = G("ㅛㅒ"),
	 = G("ㅛㅣ"),
	 = G("ㅜ"),
	 = G("ㅜㅓ"),
	 = G("ㅜㅔ"),
	 = G("ㅜㅣ"),
	 = G("ㅠ"),
	 = G("ㅠㅕ"),
	 = G("ㅠㅖ"),
	 = G("ㅠㅣ"),
	 = G("ㅡ"),
	 = G("ㅡㅣ"),
	 = G("ㅣ"),
	 = G("ㆍ"),
	 = G("ㆍㅣ"),
}

prefix = us.char(0x318F)
local final_consonants = {
	 = G("ㄱ"),
	 = G("ㄱㄱ"),
	 = G("ㄱㅅ"),
	 = G("ㄴ"),
	 = G("ㄴㄷ"),
	 = G("ㄴㅅ"),
	 = G("ㄴㅅㅎ"), -- hack
	 = G("ㄴㅈ"),
	 = G("ㄴㅌ"),
	 = G("ㄴㅎ"),
	 = G("ㄷ"),
	 = G("ㄹ"),
	 = G("ㄹㄱ"),
	 = G("ㄹㄱㅅ"),
	 = G("ㄹㅁ"),
	 = G("ㄹㅂ"),
	 = G("ㄹㅅ"),
	 = G("ㄹㅅㅎ"), -- hack
	 = G("ㄹㅌ"),
	 = G("ㄹㅍ"),
	 = G("ㄹㅎ"),
	 = G("ㄹㆆ"),
	 = G("ㅁ"),
	 = G("ㅁㄱ"),
	 = G("ㅁㅂ"),
	 = G("ㅁㅅ"),
	 = G("ㅁㅅㅎ"),
	 = G("ㅁㅊ"),
	 = G("ㅂ"),
	 = G("ㅂㄹ"),
	 = G("ㅂㅅ"),
	 = G("ㅅ"),
	 = G("ㅅㄱ"),
	 = G("ㅅㄷ"),
	 = G("ㅅㅅ"),
	 = G("ㅅㅎ"), -- hack
	 = G("ㅇ"),
	 = G("ㅇㅎ"), -- hack
	 = G("ㅇㅎㅅ"), -- hack
	 = G("ㅈ"),
	 = G("ㅊ"),
	 = G("ㅋ"),
	 = G("ㅌ"),
	 = G("ㅍ"),
	 = G("ㅎ"),
}

function export.makeSortKey(text, lang, sc)
	text = us.toNFD(text)
	text, _ = us.gsub(text, '.', initial_consonants)
	text, _ = us.gsub(text, '.', medials)
	text, _ = us.gsub(text, '.', final_consonants)
	return text
end

return export