local export = {}
local decompose = mw.ustring.toNFD
local upper = mw.ustring.upper
local UTF8Char = "[%z\1-\127\194-\244][\128-\191]*"
local m_data = mw.loadData("Module:grc-utilities/data")
local diacritics = m_data.diacritics
local macron = diacritics.macron
local breve = diacritics.breve
local rough = diacritics.rough
local smooth = diacritics.smooth
local diaeresis = diacritics.diaeresis
local acute = diacritics.acute
local grave = diacritics.grave
local circumflex = diacritics.circum
local subscript = diacritics.subscript
--[=[
-- Copy of data from [[Module:languages/data3/g]].
local sort_key = {
from = {"[ᾳάᾴὰᾲᾶᾷἀᾀἄᾄἂᾂἆᾆἁᾁἅᾅἃᾃἇᾇᾱᾰᾍ]", "[έὲἐἔἒἑἕἓ]", "[ῃήῄὴῂῆῇἠᾐἤᾔἢᾒἦᾖἡᾑἥᾕἣᾓἧᾗ]", "[ίὶῖἰἴἲἶἱἵἳἷϊΐῒῗῑῐ]", "[όὸὀὄὂὁὅὃ]", "[ύὺῦὐὔὒὖὑὕὓὗϋΰῢῧῡῠ]", "[ῳώῴὼῲῶῷὠᾠὤᾤὢᾢὦᾦὡᾡὥᾥὣᾣὧᾧᾨ]", "ῥ", "ς","["..MACRON..BREVE..ACUTE..GRAVE..CIRC..DIAER..COMMA..REV_COMMA..UNDERTIE.."]"},
to = {"α" , "ε" , "η" , "ι" , "ο" , "υ" , "ω" , "ρ", "σ",""}
}
local entry_name = {
from = {"[ᾸᾹ]", "[ᾰᾱ]", "[ῘῙ]", "[ῐῑ]", "[ῨῩ]", "[ῠῡ]", "µ", "["..RSQUO..PSILI..CORONIS.."]", "["..MACRON..BREVE..UNDERTIE.."]" },
to = {"Α", "α", "Ι", "ι", "Υ", "υ", "μ", "'", ""}
}
--]=]
local function replaceWithEmpty(listOfChars)
local set = {}
for _, char in ipairs(listOfChars) do
set[char] = ""
end
return set
end
local function removeDiacritics(text, diacriticList)
return (string.gsub(decompose(text), UTF8Char, replaceWithEmpty(diacriticList)))
end
function export.makeSortKey(text)
return upper(removeDiacritics(text, {
macron, breve, rough, smooth, diaeresis, acute, grave, circumflex,
subscript
}))
end
function export.makeEntryName(text)
return removeDiacritics(text, { macron, breve })
end
return export