Modulo:vec-pron
Come che se vede
La documentazione per questo modulo può essere creata in Modulo:vec-pron/man
--import ca.wiki module:ca-pron, and costumiz. for vec--
local p = {}
local utils = require('module:utilitats')
local function format_afi(text)
return '<span class="IPA" title="pronunsa AFI">' .. text .. '</span>'
end
-- Funsion de entrada modelo vec-pron
function p.modelo(frame)
local args = frame:getParent().args
local pagename = mw.ustring.lower(mw.title.getCurrentTitle().subpageText)
local namespace = mw.title.getCurrentTitle().nsText
local pron = {}
if args[1] and string.find(args[1], "/") then
pron.gen = args[1]
end
pron.gen2 = args[2]
pron.gen3 = args[3]
pron.ori = args["or"]
pron.ori2 = args["or2"]
pron.osi = args["osi"]
pron.osi2 = args["osi2"]
pron.sen = args["sentr"]
pron.sen2 = args["sentr2"]
pron.tal = args["tal"]
pron.tal2 = args["tal2"]
pron.set = args["sete"]
pron.chip = args["chip"]
pron.noc = args["n-osi"] or args["nosi"]
pron.noc2 = args["n-osi2"] or args["nosi2"]
pron.val = args["val"]
pron.val2 = args["val2"]
local numPron = 0
for k, v in pairs(pron) do
if not string.find(k, "2$") and v ~= "" and v ~= "-" then
numPron = numPron + 1
end
end
if numPron == 0 then
if namespace == "modèl" then
pron.gen = "/pɾuˈnun.si.ə/"
numPron = 1
else
-- pronúncia automàtica
pron = require("Module:vec-pron/AFI").show(args[1] or pagename)
if pron == '' then
if args.prova then
return ':* Vocal tònica ambigua'
else
return '[[Categoria:Parole in vèneto sensa transcrision fonètega]]'
end
end
pron.chip = args["+chip"]
pron.set = args["+sete"]
if args["+tal"] then
pron.tal = args["+tal"]
pron.tal2 = nil
elseif args["tal"] == "-" then
pron.tal, pron.tal2 = nil, nil
if pron.sen ~= nil and pron.chip == nil and pron.set == nil then
pron.ori = pron.sen
pron.sen = nil
end
end
for k, v in pairs(pron) do
if not string.find(k, "2$") then
numPron = numPron + 1
end
end
end
end
pron.inf = args["informal"]
pron.infq = args["inf_q"]
pron.inf2 = args["informal2"]
pron.inf2q = args["inf2_q"]
pron.inf3 = args["informal3"]
pron.inf3q = args["inf3_q"]
pron.rima = args["rima"]
pron.q = args["q"]
-- Formatació
local ret = {}
table.insert(ret, ':*<span style="font-weight: bold;">Pronunsa</span><sup>[[Wikisionàrio:Pronunsa del vèneto|(i)]]</sup>: ')
if pron.q then
table.insert(ret, '(' .. pron.q .. ') ')
end
local dueslinies = numPron > 2 and (pron.ori or pron.sen or pron.set) and (pron.osi or pron.noc or pron.val)
local oriosi = pron.ori and pron.osi and not (pron.sen or pron.set or pron.tal or pron.chip or pron.noc)
local comma = false
if pron.gen then
table.insert(ret, format_afi(pron.gen))
if pron.gen2 then
table.insert(ret, ', ' .. format_afi(pron.gen2))
if pron.gen3 then
table.insert(ret, ', ' .. format_afi(pron.gen3))
end
end
comma = true
end
if dueslinies then
table.insert(ret, '\n:: orientałe: ')
comma = false
end
if pron.ori then
if dueslinies then
table.insert(ret, format_afi(pron.ori))
elseif oriosi then
table.insert(ret, 'orientałe ' .. format_afi(pron.ori))
else
table.insert(ret, (comma and ', ' or '') .. 'orientałe ' .. format_afi(pron.ori))
end
if pron.ori2 then
table.insert(ret, ', ' .. format_afi(pron.ori2))
end
comma = true
end
if pron.sen then
table.insert(ret, (comma and ', ' or '') .. 'sentrale ' .. format_afi(pron.sen))
if pron.sen2 then
table.insert(ret, ', ' .. format_afi(pron.sen2))
end
comma = true
end
if pron.set then
table.insert(ret, (comma and ', ' or '') .. 'setentrionałe ' .. format_afi(pron.set))
comma = true
end
if pron.tal then
table.insert(ret, (comma and ', ' or '') .. 'vèneto brazilegno - talian ' .. format_afi(pron.tal))
if pron.tal2 then
table.insert(ret, ', ' .. format_afi(pron.tal2))
end
comma = true
end
if pron.chip then
table.insert(ret, (comma and ', ' or '') .. 'chipilo ' .. format_afi(pron.chip))
comma = true
end
if dueslinies then
table.insert(ret, '\n:: osidentałe: ')
comma = false
end
if pron.osi then
if dueslinies then
table.insert(ret, format_afi(pron.osi))
elseif oriosi then
table.insert(ret, (comma and ', ' or '') .. 'osidentałe ' .. format_afi(pron.osi))
else
table.insert(ret, (comma and ', ' or '') .. 'osidentałe ' .. format_afi(pron.osi))
end
if pron.osi2 then
table.insert(ret, ', ' .. format_afi(pron.osi2))
end
comma = true
end
if pron.noc then
table.insert(ret, (comma and ', ' or '') .. 'nord-osidentałe ' .. format_afi(pron.noc))
if pron.noc2 then
table.insert(ret, ', ' .. format_afi(pron.noc2))
end
comma = true
end
if pron.val then
table.insert(ret, (comma and ', ' or '') .. 'sud-orientale ' .. format_afi(pron.val))
if pron.val2 then
table.insert(ret, ', ' .. format_afi(pron.val2))
end
comma = true
end
if pron.inf then
table.insert(ret, '\n:: Informal: ')
if pron.infq then
table.insert(ret, pron.infq .. ' ')
end
table.insert(ret, format_afi(pron.inf))
if pron.inf2 then
table.insert(ret, ', ')
if pron.inf2q then
table.insert(ret, pron.inf2q .. ' ')
end
table.insert(ret, format_afi(pron.inf2))
if pron.inf3 then
table.insert(ret, ', ')
if pron.inf3q then
table.insert(ret, pron.inf3q .. ' ')
end
table.insert(ret, format_afi(pron.inf3))
end
end
end
-- Rimes
-- formes generals per català osidentałe
if pron.val2 and (mw.ustring.find(pron.val2, "v") or mw.ustring.find(pron.val2, "ŋk")) then
pron.val = pron.val2
end
if mw.ustring.find(pron.noc or '', "ˈ.*i\.d͡z") and mw.ustring.find(pron.val or '', "ˈ.*i\.z") then
pron.osi = pron.noc
elseif mw.ustring.find(pron.noc or '', "ˈ.*[^͡]ʒ") and mw.ustring.find(pron.val or '', "ˈ.*d͡ʒ") then
pron.osi = mw.ustring.gsub(pron.val, "d͡ʒ", "ʒ")
elseif mw.ustring.find(pron.osi or '', "ɫ\.ɫ") then
pron.osi2 = nil
end
local pronrima = pron.rima or pron.osi2 or pron.osi or pron.val or pron.noc or pron.tal or pron.ori or pron.gen2 or pron.gen
-- sense locucions ni prefixos o sufixos
if pronrima and pronrima ~= "" and not (string.find(pagename, "[^ ]+ [^ ]+") or string.find(pagename, "^-") or string.find(pagename, "-$") or namespace ~= "") then
pronrima = mw.ustring.gsub(pronrima, "[/\%[%]]", "")
local pronrimaor = pron.sen or pron.ori or ''
pronrimaor = mw.ustring.gsub(pronrimaor, "[/\%[%]]", "")
if mw.ustring.find(pronrima, "[rɾ]s?$") and pronrimaor ~= "" and not mw.ustring.find(pronrimaor, "[rɾ]s?$") then
pronrima = mw.ustring.gsub(pronrima, "[rɾ](s?)$", "(ɾ)%1")
end
-- número de síl·labes per ordenar categoria de rimes
pronrima = mw.ustring.gsub(pronrima, "^[ˈˌ]", "")
_, numsil = mw.ustring.gsub(pronrima, "[.ˌˈ]", "")
numsil = numsil + 1
-- inici des de l'accent
local posaccent = mw.ustring.find(pronrima, "ˈ") or 0
pronrima = mw.ustring.sub(pronrima, posaccent + 1)
pronrima = mw.ustring.gsub(pronrima, "%.", "")
posaccent = mw.ustring.find(pronrimaor, "ˈ") or 0
pronrimaor = mw.ustring.sub(pronrimaor, posaccent + 1)
-- inici des de la vocal accentuada
local vocals = utils.llista({'a','e','ɛ','i','o','ɔ','u'})
local rima = ''
for i = 1, mw.ustring.len(pronrima) do
if vocals[mw.ustring.sub(pronrima, i, i)] then
rima = mw.ustring.sub(pronrima, i)
break
end
end
local rimaor = ''
for i = 1, mw.ustring.len(pronrimaor) do
if vocals[mw.ustring.sub(pronrimaor, i, i)] then
rimaor = mw.ustring.sub(pronrimaor, i)
break
end
end
-- substitució d'aproximants
local from_pron = 'βðɣɫ͡'
local to_pron = 'bdɡl'
for j = 1, mw.ustring.len(from_pron) do
rima = mw.ustring.gsub(rima, mw.ustring.sub(from_pron, j, j), mw.ustring.sub(to_pron, j, j) or '')
end
rima = mw.ustring.gsub(rima, "r([^aeiou])", "ɾ%1")
rima = mw.ustring.gsub(rima, "r$", "ɾ")
if mw.ustring.find(rima, "^e") and mw.ustring.find(rimaor, "^ɛ") then
rima = mw.ustring.gsub(rima, "^e", "ɛ")
end
textrima = p.rima(rima, numsil)
if textrima ~= '' then
table.insert(ret, '\n' .. textrima)
end
end
return table.concat(ret)
end
-- Funció d'entrada de la modelo:ca-rima i auxiliar de ca-pron
function p.rima(rima, numsil)
if type(rima) == "table" then
local args = rima:getParent().args
rima = args[1] or ''; if rima == '' then rima = '-' end
numsil = args[2] or '0'
end
-- rimes migrades a categoria
if mw.title.new("Categoria:Rimes en català -" .. rima).exists then
ret = ':*<span style="font-weight: bold;">Rimes</span>: [[:Categoria:Rimes en català -' .. rima .. '|-' .. rima .. ']]'
ret = ret .. utils.format_categories({'Rimes en català -' .. rima}, "ca", numsil)
else
ret = ''
utils.track("rimes/" .. rima)
end
return ret
end
return p