Differenze tra le versioni di "Modulo:Bananas"
| Riga 1: | Riga 1: | ||
local p={} | local p={} | ||
| − | local acute_or_grave = "[" .. mw.ustring.char(0x300, 0x301) .. "]" | + | --local acute_or_grave = "[" .. mw.ustring.char(0x300, 0x301) .. "]" |
| − | function p.word(frame) | + | --function p.word(frame) |
| − | + | -- a = mw.ustring.lower('Cé4A') | |
| − | + | -- decomposed = mw.ustring.toNFD(a) | |
| − | + | -- return decomposed | |
| + | --end | ||
| + | |||
| + | function p.word(frame) | ||
| + | local m_IPA = require "Module:IPA" | ||
| + | |||
| + | local word, voiced_z | ||
| + | if type(frame) == "table" then | ||
| + | local args = require "Module:parameters".process( | ||
| + | frame:getParent().args, | ||
| + | { | ||
| + | [1] = {}, | ||
| + | voiced = {}, -- series of numbers, or boolean | ||
| + | }) | ||
| + | |||
| + | word = args[1] | ||
| + | if args.voiced then | ||
| + | local count = 0 | ||
| + | voiced_z = require "Module:fun".map( | ||
| + | function (item) | ||
| + | count = count + 1 | ||
| + | return tonumber(item) | ||
| + | or count == 1 and require "Module:yesno"(item) -- Rejects false values. | ||
| + | or error("Invalid input '" .. item .."' in |voiced= parameter. " | ||
| + | .. "Expected number.") | ||
| + | end, | ||
| + | mw.text.split(args.voiced, "%s*,%s*")) | ||
| + | if not voiced_z[2] and type(voiced_z[1]) == "boolean" then | ||
| + | voiced_z = voiced_z[1] | ||
| + | end | ||
| + | end | ||
| + | else | ||
| + | word = frame | ||
| + | end | ||
| + | |||
| + | if not word then | ||
| + | word = mw.title.getCurrentTitle().text | ||
| + | end | ||
| + | |||
| + | local transcription = "/" .. export.to_phonemic(word, voiced_z) .. "/" | ||
| + | |||
| + | return m_IPA.format_IPA_full( | ||
| + | require "Module:languages".getByCode "it", | ||
| + | { { pron = transcription } }) | ||
end | end | ||
| − | |||
| − | |||
return p | return p | ||
Versione delle 17:48, 17 set 2018
La documentazione per questo modulo può essere creata in Modulo:Bananas/man
local p={}
--local acute_or_grave = "[" .. mw.ustring.char(0x300, 0x301) .. "]"
--function p.word(frame)
-- a = mw.ustring.lower('Cé4A')
-- decomposed = mw.ustring.toNFD(a)
-- return decomposed
--end
function p.word(frame)
local m_IPA = require "Module:IPA"
local word, voiced_z
if type(frame) == "table" then
local args = require "Module:parameters".process(
frame:getParent().args,
{
[1] = {},
voiced = {}, -- series of numbers, or boolean
})
word = args[1]
if args.voiced then
local count = 0
voiced_z = require "Module:fun".map(
function (item)
count = count + 1
return tonumber(item)
or count == 1 and require "Module:yesno"(item) -- Rejects false values.
or error("Invalid input '" .. item .."' in |voiced= parameter. "
.. "Expected number.")
end,
mw.text.split(args.voiced, "%s*,%s*"))
if not voiced_z[2] and type(voiced_z[1]) == "boolean" then
voiced_z = voiced_z[1]
end
end
else
word = frame
end
if not word then
word = mw.title.getCurrentTitle().text
end
local transcription = "/" .. export.to_phonemic(word, voiced_z) .. "/"
return m_IPA.format_IPA_full(
require "Module:languages".getByCode "it",
{ { pron = transcription } })
end
return p