Module:typing-aids/data/pra-Deva

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

This module needs documentation.
Please document this module by describing its purpose and usage on the documentation page.

local data = {}

local U = require("Module:string/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["pra-Deva"] = {
	-- Vowels and modifiers. Do the diphthongs and diaereses first.
	{"ai", "ऐ"},
	{"au", "औ"},
	{"ä", "अ"},
	{"ö", "ओ"},
	{"ï", "इ"},
	{"ü", "उ"},
	{"a", "अ"},
	{"ā", "आ"},
	{"i", "इ"},
	{"ī", "ई"},
	{"u", "उ"},
	{"ū", "ऊ"},
	{"e", "ए"},
	{"ĕ", "ऎ"},
	{"o", "ओ"},
	{"ŏ", "ऒ"},
	{"ṝ", "ॠ"},
	{"ṛ", "ऋ"},
	{"r̥", "ऋ"},
	{"ḹ", "ॡ"},
	{"ḷ", "ऌ"},
	{"(अ)[%-/]([इउ])", "%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(0x962),
	["ए"] = U(0x947),
	["ऎ"] = U(0x946),
	["ओ"] = U(0x94B),
	["ऒ"] = U(0x94A),
	["आ"] = U(0x93E),
	["ई"] = U(0x940),
	["ऊ"] = U(0x942),
	["ॠ"] = U(0x944),
	["ॡ"] = U(0x963),
	["ऐ"] = 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["pra-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["pra-Deva"], {"(" .. consonant .. ")अ", "%1"})

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

return data