मॉड्यूल:bho-IPA
"इस मॉड्यूल हेतु प्रलेख मॉड्यूल:bho-IPA/doc पर बनाया जा सकता है"
local export = {}
local lang = require("Module:languages").getByCode("bho")
local sc = require("Module:scripts").getByCode("Deva")
local m_IPA = require("Module:IPA")
local gsub = mw.ustring.gsub
local gmatch = mw.ustring.gmatch
local find = mw.ustring.find
local correspondences = {
["ṅ"] = "ŋ", ["g"] = "ɡ",
["c"] = "ʦ", ["j"] = "ʣ", ["ñ"] = "ɲ",
["ṭ"] = "ʈ", ["ḍ"] = "ɖ", ["ṇ"] = "ɳ",
["t"] = "t", ["d"] = "d",
["y"] = "j", ["v"] = "ʋ", ["l"] = "l",
["ś"] = "s", ["ṣ"] = "s", ["h"] = "ɦ",
["ṛ"] = "ɽ", ["n"] = "n", ["ž"] = "ʒ", ["z"] = "z", ["ṟ"] = "ɹ", ["r̥"] = "ri", ["r̥̄"] = "riː", ["ṃ"] = "̃", ["ॽ"] = "", [","] = ",", ["r"] = "ɾ", ["ỹ"] = "j̃",
["a"] = "ə", ["ā"] = "aː", ["i"] = "ɪ", ["ī"] = "iː", ["o"] = "o", ["e"] = "e", ["ē"] = "eː", ["u"] = "ʊ", ["ū"] = "uː", ["ō"] = "oː", ["ŏ"] = "ɔ", ["ĕ"] = "æ", ["’"] = "ː", ["²"] = "ː",["ê"] = "æ", ["ô"] = "ɔ", ["ï"] = "ĭ", ["ü"] = "ŭ",
["ḥ"] = "ʰ", [" "] = " ",
}
local vowels = "aāā̃ẽõiīuūᵊːɔʊi̯u̯âäæeī̃ū̃ĩôoʌʌ̃ãũŏĕ̤"
local weak_h_c = "gjʣdḍd̪ṇɽbnmlṛvrɾṟwy"
local weak_h = "([" .. weak_h_c .. "])h"
local aspirate = "([kctṭt̪pʦ])"
local syllabify_pattern = "([" .. vowels .. "]+)([^" .. vowels .. "%.]+)([" .. vowels .."]+)"
local function find_consonants(text)
local current = ""
local cons = {}
for cc in mw.ustring.gcodepoint(text .. " ") do
local ch = mw.ustring.char(cc)
if find(current .. ch, "^[kgṅcjñṭḍṇɽtdnpbmɽ̃yrlɳwvɾjwśṣshqxġzžḻṛṟfθðṉ]$") or find(current .. ch, "^[kgcjṭḍṇtɽdɽ̃pbṛṟ]h$") then
current = current .. ch
else
table.insert(cons, current)
current = ch
end
end
return cons
end
local function syllabify(text)
for count = 1, 2 do
text = gsub(text, syllabify_pattern, function(a, b, c)
b_set = find_consonants(b)
table.insert(b_set, #b_set > 1 and 2 or 1, "")
return a .. table.concat(b_set) .. c
end)
end
return text
end
local identical = "knlsfzθð"
for character in gmatch(identical, ".") do
correspondences[character] = character
end
local function transliterate(text)
return (lang:transliterate(text))
end
function export.link(term)
return require("Module:links").full_link{ term = term, lang = lang, sc = sc }
end
function export.toIPA(text, phonetic)
local translit = transliterate(text)
if not translit then
error('The term "' .. Bhojpuri .. '" could not be transliterated.')
end
if phonetic then
end
local result = gsub(translit, ".", correspondences)
translit = gsub(translit, "͠", "̃")
translit = gsub(translit, 'a(̃?)i', 'ɛ%1')
translit = gsub(translit, 'a(̃?)u', 'ɔ%1')
translit = gsub(translit, "rr̥", "ri")
translit = gsub(translit, "rr̥̄", "riː")
translit = gsub(translit, "%-", " ")
translit = gsub(translit, "r̥", "ri")
translit = gsub(translit, "r̥̄", "riː")
translit = syllabify(translit)
-- aspiration rules
translit = gsub(translit, aspirate .. "h", '%1ʰ')
translit = gsub(translit, weak_h, '%1ʱ')
translit = gsub(translit, '([' .. weak_h_c .. '])%.h', '.%1ʱ')
translit = gsub(translit, aspirate .. '%.h', '.%1ʰ')
translit = gsub(translit, "%.ː", "ː.")
local result = gsub(translit, ".", correspondences)
-- formatting
result= gsub(result, "([aāäeâôoʌiuɪʊe̯eëəᵊ])(ː)([kɦgɕʑṅcjñṭḍṇɽtdnʦʣʰʱpbmɽ̃yrlɳwvɾjwśṣshqxġzžḻṛṟfθðṉ]?)([aāäeâôoʌiuɪʊɨʉe̯eëəᵊ])(ː?)([kɦgṅcjʰʱñṭḍṇɽtdnpbmɽ̃yrlɳwvɾjwśṣshqxġzžḻṛṟfθðṉ]?)([kɦgṅcjñṭḍṇɽtdnpbmɽ̃yrlɳwvɾjwśṣsʰʱhɕʑqxʦʣġzžḻṛṟfθðṉɨʉ]?)([aāäeâôoʌiuɪʊe̯eëəᵊ])(ː?)$", "%1ˑ%3%4%5%6%7%8%9")
result= gsub(result, "([aāäeâôoʌiuɪʊe̯eëəᵊ])(ː)([kɦgṅʦʣcɕʑjñṭḍṇɽtdnpbmɽ̃yrʰʱlɳwvɾjwśṣshqxġzžḻṛṟfθðṉ]?)([aāäeâôoʌiuɪʊɨʉe̯eëəᵊ])(ː?)([kɦgṅcjñṭḍɕʑʦʣṇɽtdnpbmʰʱɽ̃yrlɳwvɾjwśṣshqxġzžḻṛṟfθðṉ]?)([aāäeâôoʌiuɪʊe̯eëəᵊ])(ː?)([kɦgṅcjñṭḍṇɽtdnpbmɽ̃yɕʑrlɳʦʣwvɾjwśṣsʰʱhqxġzžḻṛṟfθðṉɨʉ]?)$", "%1ˑ%3%4%5%6%7%8%9")
result= gsub(result, "([aāäeâôoʌiuɪʊe̯eëəᵊ])(ː)([kɦgɕʑṅcjñṭḍṇɽtdnʦʣʰʱpbmɽ̃yrlɳwvɾjwśṣshqxġzžḻṛṟfθðṉ]?)([aāäeâôoʌiuɪʊɨʉe̯eëəᵊ])(ː?)([kɦgṅcjʰʱñṭḍṇɽtdnpbmɽ̃yrlɳwvɾjwśṣshqxġzžḻṛṟfθðṉ]?)([kɦgṅcjñṭḍṇɽtdnpbmɽ̃yrlɳwvɾjwśṣsʰʱhɕʑqxʦʣġzžḻṛṟfθðṉɨʉ]?)([aāäeâôoʌiuɪʊe̯eëəᵊ])(ː?) ", "%1ˑ%3%4%5%6%7%8%9 ")
result= gsub(result, "([aāäeâôoʌiuɪʊe̯eëəᵊ])(ː)([kɦgṅʦʣcɕʑjñṭḍṇɽtdnpbmɽ̃yrʰʱlɳwvɾjwśṣshqxġzžḻṛṟfθðṉ]?)([aāäeâôoʌiuɪʊɨʉe̯eëəᵊ])(ː?)([kɦgṅcjñṭḍɕʑʦʣṇɽtdnpbmʰʱɽ̃yrlɳwvɾjwśṣshqxġzžḻṛṟfθðṉ]?)([aāäeâôoʌiuɪʊe̯eëəᵊ])(ː?)([kɦgṅcjñṭḍṇɽtdnpbmɽ̃yɕʑrlɳʦʣwvɾjwśṣsʰʱhqxġzžḻṛṟfθðṉɨʉ]?) ", "%1ˑ%3%4%5%6%7%8%9 ")
result = gsub(result, "(...)ə$", "%1ᵊ")
result = gsub(result, "(...)ə ", "%1ᵊ ")
result = gsub(result, "(...)ə%.?%-", "%1ᵊ-")
result = gsub(result, "ʊ(̃?)(ʱ?)$", "u%1%2")
result = gsub(result, "ɪ(̃?)(ʱ?)$", "i%1%2")
result = gsub(result, "ɔ(̃?)ʋ", "əu̯")
result = gsub(result, "ɛ(̃?)j", "əi̯")
result = gsub(result, "ː̃", "̃ː")
result = gsub(result, "ː.̃", "̃ː.")
result = gsub(result, "%. ", " ")
result = gsub(result, "%.$", " ")
result = gsub(result, "%.?%-", ".")
result = gsub(result, "ː%.̃", "̃ː.")
result = gsub(result, "([td])", "%1̪")
result = gsub(result, "ʦ", "t͡ɕ")
result = gsub(result, "ʣ", "d͡ʑ")
result = gsub(result, "aˑ", "ə")
result = gsub(result, "iˑ", "ɪ")
result = gsub(result, "uˑ", "ʊ")
result = gsub(result, "eˑ", "e")
result = gsub(result, "oˑ", "o")
result = gsub(result, "āˑ", "ə")
result = gsub(result, "īˑ", "ɪ")
result = gsub(result, "ūˑ", "ʊ")
result = gsub(result, "ēˑ", "e")
result = gsub(result, "ōˑ", "o")
return result
end
function export.make(frame)
local args = frame:getParent().args
local pagetitle = mw.title.getCurrentTitle().text
local p, results = {}, {}
if args[1] then
for index, item in ipairs(args) do
table.insert(p, (item ~= "") and item or nil)
end
else
p = { pagetitle }
end
for _, Bhojpuri in ipairs(p) do
table.insert(results, { pron = "/" .. export.toIPA(Bhojpuri) .. "/" })
if export.toIPA(Bhojpuri, true) ~= export.toIPA(Bhojpuri) then
table.insert(results, { pron = "[" .. export.toIPA(Bhojpuri, true) .. "]" })
end
end
return m_IPA.format_IPA_full(lang, results)
end
return export