Module:typing-aids/data/omr-Deva

From Wiktionary, the free dictionary
Jump to navigation Jump to search

local data = {}

local U = mw.ustring.char

local anusvAra = U(0x902)
local visarga = U(0x903)
local virAma = U(0x94D)
local avagraha = "ऽ"
local consonants = "कखगघङचछजझञटठडढणतथदधनपफबभमयरलळवशषसह"
local consonant = "[" .. consonants .. "]"

local acute = U(0x301)		-- combining acute

data["omr-Deva"] = {
	-- Vowels and modifiers. Do the diphthongs and diaereses first.
	{"ai", "ऐ"},
	{"au", "औ"},
	{"ä", "अ"},
	{"ö", "ओ"},
	{"ï", "इ"},
	{"ü", "उ"},
	{"a", "अ"},
	{"ā", "आ"},
	{"i", "इ"},
	{"ī", "ई"},
	{"u", "उ"},
	{"ū", "ऊ"},
	{"e", "ए"},
	{"o", "ओ"},
	{"ṝ", "ॠ"},
	{"ṛ", "ऋ"},
	{"r̥", "ऋ"},
	{"ḹ", "ॡ"},
	{"l̥̄", "ॡ"},
	{"ḷ", "ळ"},
	{"(अ)[%-/]([इउ])", "%1%2"},		-- a-i, a-u for अइ, अउ; must follow rules for "ai", "au"

	-- Two-letter consonants must go before h.
	{"kh", "ख"},
	{"gh", "घ"},
	{"ch", "छ"},
	{"jh", "झ"},
	{"ṭh", "ठ"},
	{"ḍh", "ढ"},
	{"th", "थ"},
	{"dh", "ध"},
	{"ph", "फ"},
	{"bh", "भ"},
	{"h", "ह"},

	-- Other stops.
	{"k", "क"},
	{"g", "ग"},
	{"c", "च"},
	{"j", "ज"},
	{"ṭ", "ट"},
	{"ḍ", "ड"},
	{"t", "त"},
	{"d", "द"},
	{"p", "प"},
	{"b", "ब"},

	-- Nasals.
	{"ṅ", "ङ"},
	{"ñ", "ञ"},
	{"ṇ", "ण"},
	{"n", "न"},
	{"n", "न"},
	{"m", "म"},

	-- Remaining consonants.
	{"y", "य"},
	{"r", "र"},
	{"l", "ल"},
	{"v", "व"},
	{"ś", "श"},
	{"ṣ", "ष"},
	{"s", "स"},

	{"ṃ", anusvAra},
	{"ḥ", visarga},
	{"'", avagraha},
	-- This rule must be applied twice because a consonant may only be in one capture per operation,
	-- so "CCC" will only recognize the first two consonants. Must follow all consonant conversions.
	{"(" .. consonant .. ")(" .. consonant .. ")", "%1" .. virAma .. "%2"},
	{"(" .. consonant .. ")(" .. consonant .. ")", "%1" .. virAma .. "%2"},
	{"(" .. consonant .. ")$", "%1" .. virAma},
	{acute, ""},
}

local vowels = {
	["इ"] = U(0x93F),
	["उ"] = U(0x941),
	["ऋ"] = U(0x943),
	["ए"] = U(0x947),
	["ओ"] = U(0x94B),
	["आ"] = U(0x93E),
	["ई"] = U(0x940),
	["ऊ"] = U(0x942),
	["ऐ"] = U(0x948),
	["औ"] = U(0x94C),
}

-- Convert independent vowels to diacritics after consonants. Must go after all consonant conversions.
for independentForm, diacriticalForm in pairs(vowels) do
	table.insert(data["omr-Deva"], {"(" .. consonant .. ")" .. independentForm, "%1" .. diacriticalForm})
end

-- This must go last, after independent vowels are converted to diacritics, or "aï", "aü" won't work.
table.insert(data["omr-Deva"], {"(" .. consonant .. ")अ", "%1"})

-- [[w:Harvard-Kyoto]] to [[w:International Alphabet of Sanskrit Transliteration]]
data["omr-Deva-tr"] = {
	[1] = {
		["A"] = "ā",
		["I"] = "ī",
		["U"] = "ū",
		["J"] = "ñ",
		["T"] = "ṭ",
		["D"] = "ḍ",
		["N"] = "ṇ",
		["G"] = "ṅ",
		["z"] = "ś",
		["S"] = "ṣ",
		["M"] = "ṃ",
		["L"] = "ḷ",
		["H"] = "ḥ",
		["LRR"] = "ḹ",
		["/"] = acute,
	},
	[2] = {
		["RR"] = "ṝ",
	},
	[3] = {
		["R"] = "ṛ",
	},
}

return data