Module:User:BajookThug/IPAtest

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


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