local tests = require("Module:UnitTests")
local m_IPA = require("Module:mr-IPA")
local function tag_IPA(IPA)
return '<span class="IPA">' .. IPA .. '</span>'
end
function tests:check_output(term, expected, comment)
self:equals(
m_IPA.link(term),
tag_IPA(m_IPA.toIPA(term, false)),
tag_IPA(expected),
{ comment = comment }
)
end
function tests:check_output_phonetic(term, expected, comment)
self:equals(
m_IPA.link(term),
tag_IPA(m_IPA.toIPA(term, true)),
tag_IPA(expected),
{ comment = comment }
)
end
function tests:test_all()
examples = {
-- /Broad transcription/
-- Syllabification
-- ळ Syllabification
-- ळ Syllabification: Word-final, Syllable-final, One Syllable ⟨σ⟩
{ "ओळ", "oɭ̆", [=[ [[ळ]] Syllabification: ⟨σ⟩, Word-final, Syllable-final: Vɭ̆]=] },
{ "वेळ", "ʋeɭ̆", [=[ [[ळ]] Syllabification: ⟨σ⟩, Word-final, Syllable-final: CVɭ̆]=] },
-- ळ Syllabification: Word-final, Syllable-final, Two Syllables ⟨σσ⟩
{ "देऊळ", "d̪e.uɭ̆", [=[ [[ळ]] Syllabification: ⟨σσ⟩, Word-final, Syllable-final: Vɭ̆]=] },
{ "केवळ", "ke.ʋəɭ̆", [=[ [[ळ]] Syllabification: ⟨σσ⟩, Word-final, Syllable-final: CVɭ̆]=] },
-- ळ Syllabification: Word-medial, Syllable-final
{ "आळशी", "aɭ̆.ɕi", [=[ [[ळ]] Syllabification: ⟨σσ⟩, Word-medial, Syllable-final: Vɭ̆]=] },
{ "काळजी", "kaɭ̆.d͡ʑi", [=[ [[ळ]] Syllabification: ⟨σσ⟩, Word-medial, Syllable-final: CVɭ̆]=] },
-- ळ Syllabification: Word-medial, Syllable-initial
{ "मुळे", "mu.ɭ̆e", [=[ [[ळ]] Syllabification: ⟨σσ⟩, Word-medial, Syllable-initial: ɭ̆V]=] },
{ "आळस", "a.ɭ̆əs", [=[ [[ळ]] Syllabification: ⟨σσ⟩, Word-medial, syllable-initial: ɭ̆VC]=] },
-- /t͡s/, /d͡z/ syllabification: Word-medial
{ "डिवच़णे", "ɖi.ʋət͡s.ɳe", [=[ /t͡s/: Word-medial]=] },
{ "खेच़णे", "kʰet͡s.ɳe", [=[ /t͡s/: Word-medial]=] },
{ "अंदाज़", "ən.d̪ad͡z", [=[ /d͡z/: Word-final]=] },
{ "अंदाज़े", "ən.d̪a.d͡ze", [=[ /d͡z/: Word-medial]=] },
{ "अवहेलना", "əʋ.ɦel.na", [=[ Murmur rule in broad transcription: ʋ.ɦ → ʋʱ ]=] },
-- Consonant clusters and geminates
-- Word-final consonant clusters and geminates
{ "मार्ग", "maɾ.ɡə", [=[ Word-final codas: Consonant clusters]=] },
{ "खुद्द", "kʰud̪.d̪ə", [=[ Word-final codas: Geminates]=] },
-- Aspirated geminates: orthographic CʰCʰ → phonological CCʰ
{ "अख्खे", "ək.kʰe", [=[ Aspirated geminates: ख्ख]=] },
{ "पुठ्ठा", "puʈ.ʈʰa", [=[ Aspirated geminates: ठ्ठ]=] },
-- Fundamental tests
-- Vowels
-- Non-word-final ई, ऊ
{ "ईशान्य", "i.ɕan.jə", [=[ Non-word-final [[ई]], [[ऊ]]: [[ई]] Independent ]=] },
{ "ऊर्फ", "uɾ.pʰə", [=[ Non-word-final [[ई]], [[ऊ]]: [[ऊ]] Independent ]=] },
{ "श्रीमंत", "ɕɾi.mən.t̪ə", [=[ Non-word-final [[ई]], [[ऊ]]: [[ई]] Diacritic ]=] },
{ "पूर्ण", "puɾ.ɳə", [=[ Non-word-final [[ई]], [[ऊ]]: [[ऊ]] Diacritic ]=] },
-- Diphthongs
{ "ऐक", "əik", [=[ Diphthongs: [[ऐ]] Independent, Stem of [[ऐकणे]]]=] },
{ "हौस", "ɦəus", [=[ Diphthongs: [[औ]] Diacritic]=] },
-- ऋ
{ "ऋण", "ɾuɳ", [=[ [[ऋ]]: Independent]=] },
{ "कृपा", "kɾu.pa", [=[ [[ऋ]]: Diacritic]=] },
-- Consonants
-- ल
{ "लाल", "lal", [=[ [[ल]]: Checks if [[ल]] is /l/ or /l̪/]=]},
-- ऱ् (Eyelash र)
{ "ऱ्हास", "ɾʱas", [=[ Eyelash र: Word-initial ऱ्ह]=] },
{ "गोऱ्हा", "ɡo.ɾʱa", [=[ Eyelash र: Word-medial ऱ्ह]=] },
{ "दऱ्या", "d̪ə.ɾja", [=[ Eyelash र: /ɾ/ moves to following syllable, Plural of [[दरी]]]=] },
{ "दर्या", "d̪əɾ.ja", [=[ Eyelash र: For comparison with दऱ्या]=] },
-- /ŋ/: Velar nasal
{ "सांग", "saŋ.ɡə", [=[ /ŋ/: Stem-final, Stem of [[सांगणे]]]=] },
{ "कंगवा", "kəŋ.ɡʋa", [=[ /ŋ/: Word-medial]=] },
{ "पलंग", "pə.ləŋ.ɡə", [=[ /ŋ/: Word-final]=] },
-- Spelt mumured consonants: न्ह, म्ह, ल्ह, व्ह
{ "न्हावी", "nʱa.ʋi", [=[ Spelt mumured consonants: Word-initial न्ह]=] },
{ "तान्हा", "t̪a.nʱa", [=[ Spelt mumured consonants: Word-medial न्ह]=] },
{ "म्हण", "mʱəɳ", [=[ Spelt mumured consonants: Word-initial म्ह]=] },
{ "आम्ही", "a.mʱi", [=[ Spelt mumured consonants: Word-medial म्ह]=] },
{ "जिल्हा", "d͡ʑi.lʱa", [=[ Spelt mumured consonants: Word-medial ल्ह]=] },
{ "व्हा", "ʋʱa", [=[ Spelt mumured consonants: Word-initial व्ह]=] },
{ "नव्हे", "nə.ʋʱe", [=[ Spelt mumured consonants: Word-medial व्ह]=] },
-- य
-- य: Word-final
{ "काय", "kaj", [=[ [[य]]: ⟨σ⟩, Word-final, Syllable-final: Vj]=] },
{ "उदय", "u.d̪əj", [=[ [[य]]: ⟨σσ⟩, Word-final, Syllable-final: CVj]=] },
-- य: Word-medial
{ "आयते", "aj.t̪e", [=[ [[य]]: ⟨σσ⟩, Word-medial, Syllable-final: Vj]=] },
{ "फायदा", "pʰaj.d̪a", [=[ [[य]]: ⟨σσ⟩, Word-medial, Syllable-final: CVj]=] },
{ "नायक", "na.jək", [=[ [[य]]: ⟨σσ⟩, Word-medial, Syllable-initial: jVC]=] },
-- ज्ञ
{ "ज्ञान", "d̪njan", [=[ [[ज्ञ]]: Word-initial]=] },
{ "आज्ञा", "ad̪.nja", [=[ [[ज्ञ]]: Word-medial]=] },
-- ह: Word-final
{ "मोह", "moɦ", [=[ [[ह]]: ⟨σ⟩, Word-final]=] },
-- English borrowings (See [[MOD:mr-translit]] for details)
{ "ॲप्", "æp", [=[ English: [[ॲ]] Independent, [[app]]]=] },
{ "ऍप्", "æp", [=[ English: [[ऍ]] Independent, [[app]]]=] },
{ "ऑस्ट्रेलिया", "ɔs.ʈɾe.li.ja", [=[ English: [[ऑ]] Independent, [[Australia]] ]=] },
{ "बॅट", "bæʈ", [=[ English: [[ॲ]] Diacritic, [[bat]]]=] },
{ "कॉट", "kɔʈ", [=[ English: [[ऑ]] Diacritic, [[cot]]]=] },
{ "बँक्", "bæŋk", [=[ English: [[अँ]] Diacritic, [[bank]]]=] },
{ "ऑगस्ट्", "ɔ.ɡəsʈ", [=[ English: Syllable-final CC, [[August]] ]=] },
{ "काँग्रेस", "kɔŋ.ɡɾes", [=[ English: आँ Diacritic, [[Congress]], Hindi [[कांग्रेस]] ]=] },
{ "हाँग्-काँग्", "ɦɔŋɡ‿kɔŋɡ", [=[ English: Multiword term [[Hong Kong]], Hindi [[हांग कांग]] ]=] },
}--[[ Copy the following to add more examples:
{ "", "" },
]]
tests:iterate(examples, "check_output")
end
function tests:test_phonetic()
examples = {
-- [Narrow transcription]
-- Final syllable high vowels
-- Open syllables
{ "ऊ", "uː", [=[ Final syllable high vowels: [[ऊ]] Independent, Open syllables ]=] },
{ "मी", "miː", [=[ Final syllable high vowels: [[ई]] Diacritic, Open syllables ]=] },
{ "तू", "t̪uː", [=[ Final syllable high vowels: [[ऊ]] Diacritic, Open syllables ]=] },
{ "आणि", "a.ɳiː", [=[ Final syllable high vowels: [[इ]] Diacritic, Open syllables ]=] },
{ "परंतु", "pə.ɾən.t̪uː", [=[ Final syllable high vowels: [[उ]] Diacritic, Open syllables ]=] },
-- Closed syllables
{ "उत", "uːt̪", [=[ Final syllable high vowels: [[उ]] Independent, Closed syllables ]=] },
{ "तपशील", "t̪əp.ɕiːl", [=[ Final syllable high vowels: [[ई]] Diacritic, Closed syllables ]=] },
{ "कबूल", "kə.buːl", [=[ Final syllable high vowels: [[ऊ]] Diacritic, Closed syllables ]=] },
{ "गणित", "ɡə.ɳiːt̪", [=[ Final syllable high vowels: [[इ]] Diacritic, Closed syllables ]=] },
{ "खुश", "kʰuːɕ", [=[ Final syllable high vowels: [[उ]] Diacritic, Closed syllables ]=] },
-- Murmur rule and ɦ-deletion in the environment CV₁_[V₂, C₂]
-- Murmur rule: result has Cʱ
-- C murmur class = /m/, /n/, /l/, /ʋ/, /ɾ/, /d͡ʑ/, d͡z, /d̪/, /b/
-- V₁ = /ə/, /a/
-- V₂ = /i/, /u/
{ "दही", "d̪ʱəiː", [=[ Murmur rule: Cə_i → Cʱəi, C = /d̪/ ]=] },
{ "बहीण", "bʱəiːɳ", [=[ Murmur rule: Cə_i → Cʱəi, C = /b/, Konkani [[भैण]] ]=] },
{ "वहिणी", "ʋʱəi.ɳiː", [=[ Murmur rule: Cə_i → Cʱəi, C = /ʋ/ ]=] },
{ "बहुतेक", "bʱəu.t̪ek", [=[ Murmur rule: Cə_u → Cʱəu]=] },
{ "जाहिरात", "d͡ʑʱai.ɾat̪", [=[ Murmur rule: Ca_i → Cʱai]=] },
{ "बाहुली", "bʱau.liː", [=[ Murmur rule: Ca_u → Cʱau]=] },
-- V₁ ≠ /ə/, /a/, V₂ = /ə/
{ "मनोहर", "mə.nʱoɾ", [=[ Murmur rule: C[≠ /ə/, /a/]ɦə → Cʱ[≠ /ə/, /a/] ]=] },
{ "बेहद्द", "bʱed̪.d̪ə", [=[ Murmur rule: C[≠ /ə/, /a/]ɦə → Cʱ[≠ /ə/, /a/] ]=] },
-- [V₂, C₂] ≠ /i/, /u/, /o/
{ "ज़हाज़", "d͡zʱad͡z", [=[ Murmur rule: Cə_[≠ /i/, /u/, /o/] → Cʱ[≠ /i/, /u/, /o/], C = /d͡z/, V₂ = /a/ ]=] },
{ "दहा", "d̪ʱa", [=[ Murmur rule: Cə_[≠ /i/, /u/, /o/] → Cʱ[≠ /i/, /u/, /o/], C = /d̪/, V₂ = /a/, Konkani [[धा]] ]=] },
{ "उदाहरण", "u.d̪ʱa.ɾəɳ", [=[ Murmur rule: Ca_[≠ /i/, /u/, /o/ → Cʱ[≠ /i/, /u/, /o/], C = /d̪/, C₂ = /ɾ/ ]=] },
{ "नाहणे", "nʱa.ɳe", [=[ Murmur rule: Ca_[≠ /i/, /u/, /o/ → Cʱ[≠ /i/, /u/, /o/], C = /n/, C₂ = /ɳ/ ]=] },
{ "बाहेर", "bʱa.eɾ", [=[ Murmur rule: Ca_[≠ /i/, /u/, /o/ → Cʱ[≠ /i/, /u/, /o/], C = /b/, V₂ = /e/ ]=] },
{ "मेहेरबानी", "mʱeɾ.ba.niː", [=[ Murmur rule: Ca_[≠ /i/, /u/, /o/ → Cʱ[≠ /i/, /u/, /o/], C = /m/, V₁ = V₂ = /e/ ]=] },
{ "मोहीम", "mʱo.iːm", [=[ Murmur rule: Ca_[≠ /i/, /u/, /o/ → Cʱ[≠ /i/, /u/, /o/], C = /m/, V₁ = /o/, V₂ = /i/ ]=] },
{ "राहणे", "ɾʱa.ɳe", [=[ Murmur rule: Ca_[≠ /i/, /u/, /o/ → Cʱ[≠ /i/, /u/, /o/], C = /ɾ/, C₂ = /ɳ/ ]=] },
{ "लिहिणे", "lʱi.ɳe", [=[ Murmur rule: Ca_[≠ /i/, /u/, /o/ → Cʱ[≠ /i/, /u/, /o/], C = /l/, V₁ = V₂ = /i/ ]=] },
{ "वाहणे", "ʋʱa.ɳe", [=[ Murmur rule: Ca_[≠ /i/, /u/, /o/ → Cʱ[≠ /i/, /u/, /o/], C = /ʋ/, C₂ = /ɳ/ ]=] },
{ "लहान", "lʱan", [=[ Murmur rule: Cə_[≠ /i/, /u/, /o/] → Cʱ[ ≠ /i/, /u/, /o/], C = /l/, V₂ = /a/, Konkani [[लान]] ]=] },
-- ɦ-deletion: ɦ → ∅
-- C ≠ C murmur class
-- V₁ = /ə/, /a/, V₂ = /i/, /u/
{ "पहिले", "pəi.le", [=[ ɦ-deletion: ɦ → ∅ / Cə_i ]=] },
{ "सही", "səiː", [=[ ɦ-deletion: ɦ → ∅ / Cə_i ]=] },
{ "गहू", "ɡəuː", [=[ ɦ-deletion: ɦ → ∅ / Cə_u ]=] },
{ "काही", "kaiː", [=[ ɦ-deletion: ɦ → ∅ / Ca_i ]=] },
{ "पाहुणा", "pau.ɳa", [=[ ɦ-deletion: ɦ → ∅ / Ca_u ]=] },
-- V₁ = /ə/, /a/, V₂ ≠ /i/, /u/, /o/
{ "तहान", "t̪an", [=[ ɦ-deletion: ə, ɦ → ∅ / Cəɦ[≠ /i/, /u/, /o/], V₂ = /a/, Konkani [[तान]] ]=] },
{ "शहर", "ɕəɾ", [=[ ɦ-deletion: ə, ɦ → ∅ / Cəɦ[≠ /i/, /u/, /o/], C = /ɕ/, V₂ = /ə/ ]=] },
{ "सहन", "sən", [=[ ɦ-deletion: ə, ɦ → ∅ / Cəɦ[≠ /i/, /u/, /o/], C = /s/, V₂ = /ə/ ]=] },
{ "साहेब", "sa.eb", [=[ ɦ-deletion: a, ɦ → ∅ / Ca[≠ /i/, /u/, /o/]ɦ ]=] },
-- V₁ ≠ /ə/, /a/, V₂ = /ə/
{ "पेहलवान", "pel.ʋan", [=[ ɦ-deletion: ɦə → ∅ / C[≠ /ə/, /a/]_ə, ɦ-deleted spelling: [[पेलवान]] ]=] },
-- [V₂, C₂] ≠ /ə/, /i/, /u/, /o/
{ "सहमत", "sə.mət̪", [=[ ɦ-deletion: ɦ → ∅ / C[≠ /ə/, /a/]_[≠ /ə/], V₁ = /ə/, C₂ = /m/ ]=] },
{ "चेहरा", "t͡ɕe.ɾa", [=[ ɦ-deletion: ɦ → ∅ / C[≠ /ə/, /a/]_[≠ /ə/], V₁ = /e/, C₂ = /ɾ/ ]=] },
{ "पाहणे", "pa.ɳe", [=[ ɦ-deletion: ɦ → ∅ / C[≠ /ə/, /a/]_[≠ /ə/], V₁ = /a/, C₂ = /ɳ/ ]=] },
-- /t͡sʰ/: Any sequence of /ts/ → /t͡sʰ/
{ "वत्स", "ʋə.t͡sʰə", [=[ /t͡sʰ/: Word-final ]=] },
{ "मत्सर", "mə.t͡sʰəɾ", [=[ /t͡sʰ/: Word-medial ]=] },
{ "उत्साह", "u.t͡sʰa", [=[ /t͡sʰ/: Word-medial with ɦ-deletion ]=] },
-- ज्ञ
{ "ज्ञान", "njan", [=[ [[ज्ञ]]: Word-initial]=] },
}
tests:iterate(examples, "check_output_phonetic")
end
return tests