local export = {}
local lang = require("Module:languages").getByCode("pa")
local sc = require("Module:scripts").getByCode("Guru")
local m_IPA = require("Module:IPA")
local m_a = require("Module:accent qualifier")
local m_str_utils = require("Module:string utilities")
local find = m_str_utils.find
local gcodepoint = m_str_utils.gcodepoint
local gmatch = m_str_utils.gmatch
local gsub = m_str_utils.gsub
local u = m_str_utils.char
local correspondences = {
-- Consonants
= "k", = "kʰ", = "ɡ", = "kà",
= "t͡ʃ", = "t͡ʃʰ", = "d͡ʒ", = "t͡ʃà",
= "ʈ", = "ʈʰ", = "ɖ", = "ɖà",
= "t̪", = "t̪ʰ", = "d̪", = "t̪à",
= "p", = "pʰ", = "b", = "pà",
= "ŋ", = "ɳ", = "ɲ", = "n", = "m",
= "j", = "ɾ", = "l", = "ʋ",
= "ʃ", = "ʂ", = "s", = "ɦ",
= "z", = "f", = "x", = "ɣ",
-- Vowels
= "ə", = "aː", = "ɪ", = "iː",
= "ʊ", = "uː", = "eː", = "oː",
= "ɛ", = "ɔ",
-- Nasalized vowels
= "ə̃", = "ãː", = "ɪ̃", = "ĩː",
= "ʊ̃", = "ũː", = "ẽː", = "õː",
-- Tonal markers
= "à", = "è", = "ì", = "ò", = "ù"
}
local function transliterate(text)
-- Use Punjabi language module's transliteration
return lang:transliterate(text)
end
function export.toIPA(text)
-- Step 1: Transliterate Gurmukhi to Latin with tonal markers
local translit = transliterate(text)
-- Step 2: Apply phonetic transformations
translit = gsub(translit, "()h", "%1ʰ") -- Aspiration
translit = gsub(translit, "()à", "%1à") -- Tonal markers
-- Step 3: Convert to IPA symbols
local ipa = gsub(translit, ".", correspondences)
-- Step 4: Post-processing rules
ipa = gsub(ipa, "əà", "à") -- Tone placement
ipa = gsub(ipa, "aà", "à")
ipa = gsub(ipa, "()à", "à%1") -- Tone+length/nasal ordering
return ipa
end
return export