Differenze tra le versioni di "Modulo:Fan-accento"
(Creata pagina con "local export = { } local stress = "ˈ" local long = "ː" local acute_or_grave = "[" .. mw.ustring.char(0x300, 0x301) .. "]" local vowels = "æaeɛioɔu" local vowel = "[" .....") |
|||
| Riga 29: | Riga 29: | ||
word = word:gsub("ğ","ʤ") | word = word:gsub("ğ","ʤ") | ||
end | end | ||
| − | local decomposed = mw.ustring.toNFD(word) | + | local decomposed = mw.ustring.toNFD(word) |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
-- Transcriptions must contain an acute or grave, to indicate stress | -- Transcriptions must contain an acute or grave, to indicate stress | ||
-- This does not handle phrases containing more than one stressed word. | -- This does not handle phrases containing more than one stressed word. | ||
| Riga 79: | Riga 57: | ||
local transcription = decomposed | local transcription = decomposed | ||
| − | + | end | |
function export.show(frame) | function export.show(frame) | ||
Versione delle 05:18, 3 ott 2018
La documentazione per questo modulo può essere creata in Modulo:Fan-accento/man
local export = { }
local stress = "ˈ"
local long = "ː"
local acute_or_grave = "[" .. mw.ustring.char(0x300, 0x301) .. "]"
local vowels = "æaeɛioɔu"
local vowel = "[" .. vowels .. "]"
local not_vowel = "[^" .. vowels .. "]"
local front = "[eɛij]"
local fronted = mw.ustring.char(0x031F)
function export.to_accento(word)
word = mw.ustring.lower(word)
if mw.ustring.find(word,"sč") then
word = mw.ustring.toNFC(word)
--sč at the end of a word is /ʃ/
word = word:gsub("sč","ʃ")
end
if mw.ustring.find(word,"â") then
word = mw.ustring.toNFC(word)
-- â at the end of a word is /æ/
word = word:gsub("â","æ")
end
if mw.ustring.find(word,"ğ") then
word = mw.ustring.toNFC(word)
--ğ at the end of a word is /ʤ/
word = word:gsub("ğ","ʤ")
end
local decomposed = mw.ustring.toNFD(word)
-- Transcriptions must contain an acute or grave, to indicate stress
-- This does not handle phrases containing more than one stressed word.
-- Default to penultimate stress rather than throw error?
if not mw.ustring.find(decomposed, acute_or_grave) then
-- Allow monosyllabic unstressed words.
--local vowel_count = select(2, decomposed:gsub("[æaeiou]", "%1"))
--if vowel_count ~= 1 then
transcriptio=mw.ustring.sub(decomposed,-1)
if transcriptio == 'a' then
decomposed = mw.ustring.gsub(decomposed,"(" .. vowel .. ")(" .. not_vowel .. "*" .. vowel .. not_vowel .."*)$","%1" .. mw.ustring.char(0x301) .. "%2")
--end
elseif transcriptio =='e' then
decomposed = mw.ustring.gsub(decomposed,"(" .. vowel .. ")(" .. not_vowel .. "*" .. vowel .. not_vowel .."*)$","%1" .. mw.ustring.char(0x301) .. "%2")
elseif transcriptio =='o' then
decomposed = mw.ustring.gsub(decomposed,"(" .. vowel .. ")(" .. not_vowel .. "*" .. vowel .. not_vowel .."*)$","%1" .. mw.ustring.char(0x301) .. "%2")
elseif transcriptio =='i' then
decomposed = mw.ustring.gsub(decomposed,"(" .. vowel .. ")(" .. not_vowel .. "*" .. vowel .. not_vowel .."*)$","%1" .. mw.ustring.char(0x301) .. "%2")
else
decomposed=mw.ustring.gsub(decomposed,"(".. vowel ..")(" .. not_vowel .. "*)$",'%1' ..mw.ustring.char(0x301).. '%2')
end
end
local transcription = decomposed
end
function export.show(frame)
word=frame:getParent().args[1]
if not word then
word = mw.title.getCurrentTitle().text
end
transcription = "[" .. export.to_accento(word) .. "]"
return transcription
end
return export