45,337
edits
No edit summary |
No edit summary |
||
Line 7: | Line 7: | ||
local circumflex = mw.ustring.char(0x302) | local circumflex = mw.ustring.char(0x302) | ||
local acute_or_grave = "[" .. acute .. grave .. "]" | local acute_or_grave = "[" .. acute .. grave .. "]" | ||
local vowels = " | local vowels = "aeiou" | ||
local vowel = "[" .. vowels .. "]" | local vowel = "[" .. vowels .. "]" | ||
local vowel_or_semivowel = "[" .. vowels .. "jw]" | local vowel_or_semivowel = "[" .. vowels .. "jw]" | ||
local not_vowel = "[^" .. vowels .. "]" | local not_vowel = "[^" .. vowels .. "]" | ||
local front = "[ | local front = "[eij]" | ||
local fronted = mw.ustring.char(0x031F) | local fronted = mw.ustring.char(0x031F) | ||
local voiced_consonant = "[bdɡlmnrv]" | local voiced_consonant = "[bdɡlmnrv]" | ||
Line 21: | Line 21: | ||
-- voiced_z must be a table of integer indices, a boolean, or nil. | -- voiced_z must be a table of integer indices, a boolean, or nil. | ||
function export.to_phonemic(word | function export.to_phonemic(word, single_character_affricates) | ||
word = mw.ustring.lower(word):gsub("'", "") | word = mw.ustring.lower(word):gsub("'", "") | ||
-- Decompose combining characters: for instance, è → e + ◌̀ | -- Decompose combining characters: for instance, è → e + ◌̀ | ||
local decomposed = mw.ustring.toNFD(word):gsub(" | local decomposed = mw.ustring.toNFD(word):gsub("ch", "k"):gsub("ng$", "ŋ") | ||
-- Transcriptions must contain an acute or grave, to indicate stress position. | -- Transcriptions must contain an acute or grave, to indicate stress position. | ||
Line 58: | Line 49: | ||
"a(" .. grave .. "?)w", | "a(" .. grave .. "?)w", | ||
{ [""] = vowel_count == 1 and "ɔ" or "o", [grave] = "ɔ"}) | { [""] = vowel_count == 1 and "ɔ" or "o", [grave] = "ɔ"}) | ||
-- Handle gl and gn. | -- Handle gl and gn. | ||
transcription = mw.ustring.gsub(transcription, | transcription = mw.ustring.gsub(transcription, | ||
"(g[ | "(g[n])(.?)()", | ||
function (digraph, after, pos) | function (digraph, after, pos) | ||
local consonant | local consonant | ||
if digraph == "gn" then | if digraph == "gn" then | ||
consonant = "ɲ" | consonant = "ɲ" | ||
local following = mw.ustring.sub(transcription, pos, pos) | local following = mw.ustring.sub(transcription, pos, pos) | ||
Line 121: | Line 79: | ||
end | end | ||
-- | -- t is /t͡s/ before i. | ||
local consonant | local consonant | ||
if (next == "e | if (next == "i") then | ||
if first == "t" then | |||
consonant = "ʦ" | |||
else | |||
consonant = consonant | |||
end | |||
end | |||
-- c, g are soft before e, i. | |||
local consonant | |||
if (next == "e" or next == "i") then | |||
if first == "c" then | if first == "c" then | ||
consonant = "ʧ" | consonant = "ʧ" | ||
Line 135: | Line 103: | ||
consonant = "ɡ" | consonant = "ɡ" | ||
end | end | ||
end | end | ||
return consonant .. next | return consonant .. next | ||
end) | end) | ||
-- u or i (without accent) before another vowel is a semivowel. | -- u or i (without accent) before another vowel is a semivowel. | ||
Line 163: | Line 124: | ||
-- sc before e, i is /ʃ/, doubled after a vowel. | -- sc before e, i is /ʃ/, doubled after a vowel. | ||
transcription = transcription:gsub("sʧ", "ʃ") | transcription = transcription:gsub("sʧ", "ʃ") | ||
-- Move stress before syllable onset, and add syllable breaks. | -- Move stress before syllable onset, and add syllable breaks. | ||
Line 282: | Line 167: | ||
-- Incomplete and currently not used by any templates. | -- Incomplete and currently not used by any templates. | ||
function export.to_phonetic(word | function export.to_phonetic(word) | ||
local phonetic = export.to_phonemic(word | local phonetic = export.to_phonemic(word) | ||
-- Vowels longer in stressed, open, non-word-final syllables. | -- Vowels longer in stressed, open, non-word-final syllables. | ||
Line 293: | Line 178: | ||
phonetic = mw.ustring.gsub(phonetic, | phonetic = mw.ustring.gsub(phonetic, | ||
"n([%.ˈ]?[ɡk])", "ŋ%1") | "n([%.ˈ]?[ɡk])", "ŋ%1") | ||
return phonetic | return phonetic | ||
Line 320: | Line 198: | ||
local Array = require "Module:array" | local Array = require "Module:array" | ||
local transcriptions = Array(args[1]) | local transcriptions = Array(args[1]) | ||
:map( | :map( | ||
function (word, i) | function (word, i) | ||
return { pron = "/" .. export.to_phonemic(word | return { pron = "/" .. export.to_phonemic(word) .. "/" } | ||
end) | end) | ||