Module:gu-IPA/sandbox
- The following documentation is located at Module:gu-IPA/sandbox/documentation. [edit] Categories were auto-generated by Module:module categorization. [edit]
- Useful links: root page • root page’s subpages • links • transclusions • testcases • sandbox of (diff)
Gujarati IPA pronunciation module. See {{gu-IPA}}
.
Testcases
editModule:gu-IPA/sandbox/testcases:
16 of 23 tests failed. (refresh)
Text | Expected | Actual | Comments | |
---|---|---|---|---|
![]() | વખત (vakhat) | ˈʋə.kʰət̪ | ˈʋə.kʰət̪ | |
![]() | દિવસ (divas) | ˈd̪ɪ.ʋəs | ˈd̪ɪ.ʋəs | |
![]() | હદ (had) | ˈɦəd̪ | ˈɦəd̪ | |
![]() | રહેવું (rahevũ) | ˈre̤.ʋũ | ˈɾə.ɦeː.ʋũ | |
![]() | તડકો (taḍko) | ˈt̪əɖ.ko | ˈt̪əɖ.ko | |
![]() | ભાષા (bhāṣā) | ˈbʱɑ.ʃɑ | ˈbʱɑ.ʃɑ | |
![]() | છોકરું (chokrũ) | ˈt͡ʃʰok.rũ | ˈt͡ʃʰok.ɾũ | |
![]() | ઘોડું (ghoḍũ) | ˈɡʱo.ɖũ | ˈɡʱo.ɖũ | |
![]() | દૃષ્ટિ (dŕṣṭi) | ˈd̪rəʂʈi | ˈd̪ɾʊʂʈɪ | |
![]() | દૃષ્ટિ (dŕṣṭi) | ˈd̪rʊʂʈi | ˈd̪ɾʊʂʈɪ | |
![]() | ગુજરાતી (gujrātī) | ˈgʊ.d͡ʒ(ə).ˌɾɑ.t̪i | ˈɡud͡ʒ.ɾɑ.t̪i | |
![]() | પ્રાણી (prāṇī) | ˈpɾɑ.ɳi | ˈpɾɑ.ɳi | |
![]() | સાક્ષાત (sākṣāt) | ˈsɑ.kʃɑt̪ | ˈsɑk.ʃɑt̪ | |
![]() | જમવાનું (jamvānũ) | ˈd͡ʒəm.ˌʋɑ.nũ | ˈd͡ʒəm.ʋɑ.nũ | |
![]() | વિધર્મ (vidharma) | ʋɪ.d̪ʱəɾ.mə | ˈʋɪ.d̪ʱəɾ.mə | |
![]() | અંગરખો (aṅgarkho) | ˈəŋ.gəɾ.kʱo | ˈəŋ.ɡəɾ.kʰo | |
![]() | આંતરરાષ્ટ્રીય (āntarrāṣṭrīya) | ˈɑn̪.t̪əɾ.ɾɑʂ.ʈɾi.jə | ˈɑn.t̪əɾ.ɾɑʂ.ʈɾi.jə | |
![]() | આંકડાશાસ્ત્ર (ā̃kaḍāśāstra) | ˈɑ̃.k(ə).ɖɑ.ʃɑs.t̪ɾə | ˈɑ̃.kə.ɖɑ.ʃɑs.t̪ɾə | |
![]() | અહીંતહીં (ahī̃thī̃) | ˈə̤ĩ.ˌt̪ə̤ĩ | ˈə.ɦĩ.t̪ʰĩ | |
![]() | ઐતિહાસિક (aitihāsik) | əɪ̭.t̪ɪ.ɦɑ.sɪk | ˈəɪ.t̪ɪ.ɦɑ.sɪk | |
![]() | ઇસ્પિતાલ (ispitāl) | ˈɪs.pɪ.ˌt̪ɑl | ˈɪs.pɪ.t̪ɑl | |
![]() | ઉષ્ણાગ્ર (uṣṇāgra) | ˈʊʃ.ɳɑ.gɾə | ˈuʃ.ɳɑɡ.ɾə | |
![]() | ઓળખકર્તા (oḷkhakartā) | ˈo.ɭəkʱ.ˌkəɾ.t̪ɑ | ˈo.ɭkʰə.kəɾ.t̪ɑ |
local export = {}
local lang = require("Module:languages").getByCode("gu")
local sc = require("Module:scripts").getByCode("Gujr")
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"] = "t͡ʃ", ["j"] = "d͡ʒ", ["ñ"] = "ɲ",
["ṭ"] = "ʈ", ["ḍ"] = "ɖ", ["ṇ"] = "ɳ",
["t"] = "t̪", ["d"] = "d̪",
["y"] = "j", ["r"] = "ɾ", ["v"] = "ʋ", ["l"] = "l̪",
["ś"] = "ʃ", ["ṣ"] = "ʂ", ["h"] = "ɦ",
["ḷ"] = "ɭ", ["f"] = "f", ["ġ"] = "ɣ", ["ḏ"] = "ð", ["ḇ"] = "β",
["ṛ"] = "ɽ",
["a"] = "ə", ["ā"] = "ɑ", ["i"] = "ɪ",
["ī"] = "i", ["o"] = "o", ["e"] = "eː", ["ŕ"] = "ɾʊ",
["u"] = "u", ["ū"] = "u", ["ǒ"] = "ɔ", ["ɔ"] = "ɔ", ["ě"] = "ɛ", ["â"] = "æ",
["ä"] = "ə̤", ["ǟ"] = "a̤", ["ï"] = "i̤", ["ü"] = "ṳ", ["ë"] = "ɛ̤", ["ö"] = "ɔ̤",
["ॐ"] = "om", ["ḥ"] = "ʰ",
[" "] = "‿ˈ", -- get rid of spaces
}
local surati= {
["s"] = "ɦ",
}
local vowels = "aāiīuūoɔɛeæãā̃ẽĩī̃õũū̃ː"
local weak_h = "([gjdḍbṛnmaãāā̃eẽiĩīī̃uũūū̃oõː])h"
local aspirate = "([kctṭ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ñṭḍṇtdnpbmyrlvśṣsh]$") or find(current .. ch, "^[kgcjṭḍṇtdpb]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)
local result = {}
local translit = text
if lang:findBestScript(text):isTransliterated() then
translit = transliterate(text)
end
if not translit then
error('The term "' .. text .. '" could not be transliterated.')
end
local translit = gsub(translit, "͠", "̃")
local translit = gsub(translit, "%-", ".")
local translit = gsub(translit, "ṣ([^ṭḍ])", "ś%1")
local translit = syllabify(translit)
local translit = gsub(translit, 'jñ', 'gy')
local translit = gsub(translit, aspirate .. "h", '%1ʰ')
local translit = gsub(translit, weak_h, '%1ʱ')
local translit = gsub(translit, "%.ː", "ː.")
for character in gmatch(translit, ".") do
table.insert(result, correspondences[character] or character)
end
result = table.concat(result)
local result = gsub(result, "ː̃", "̃ː")
result = gsub(result, "%.‿", "‿")
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 _, Gujarati in ipairs(p) do
table.insert(results, export.toIPA(Gujarati))
end
return m_IPA.format_IPA_full { lang = lang, items = {{ pron = "/" .. table.concat(results, "/, /") .. "/" }}, }
end
return export