Module:grc
Apparence
La documentation pour ce module peut être créée à Module:grc/Documentation
-- The function p._betacode is imported from enwikt: [[en:Module:R:Perseus/polytonic-to-perseus-betacode]]
local m_params = require("Module:paramètres")
local p = {}
--- Converts an ancient greek word into its betacode.
--- @param w string The word.
--- @return string The betacode.
function p._betacode(w)
local chart = {
['ᾰ'] = 'a^', ['ᾱ'] = 'a_',
['α'] = 'a', ['ά'] = 'a/', ['ὰ'] = 'a\\', ['ᾶ'] = 'a=', ['ἀ'] = 'a)', ['ἁ'] = 'a(',
['ἂ'] = 'a)\\', ['ἃ'] = 'a(\\', ['ἄ'] = 'a)/', ['ἅ'] = 'a(/', ['ἆ'] = 'a)=', ['ἇ'] = 'a(=',
['ᾳ'] = 'a|', ['ᾴ'] = 'a/|', ['ᾲ'] = 'a\\|', ['ᾷ'] = 'a=|', ['ᾀ'] = 'a)|', ['ᾁ'] = 'a(|',
['ᾂ'] = 'a)\\|', ['ᾃ'] = 'a(\\|', ['ᾄ'] = 'a)/|', ['ᾅ'] = 'a(/|', ['ᾆ'] = 'a)=|', ['ᾇ'] = 'a(=|',
['Ᾰ'] = '*a^', ['Ᾱ'] = '*a_',
['Α'] = '*a', ['Ά'] = '*/a', ['Ὰ'] = '*a\\', ['῀Α'] = '*a=', ['Ἀ'] = '*)a', ['Ἁ'] = '*(a',
['Ἂ'] = '*)a\\', ['Ἃ'] = '*(a\\', ['Ἄ'] = '*)/a', ['Ἅ'] = '*(/a', ['Ἆ'] = '*)a=', ['Ἇ'] = '*(a=',
['ᾼ'] = '*a|', ['ᾈ'] = '*)a|', ['ᾉ'] = '*(a|',
['ᾊ'] = '*)a\\|', ['ᾋ'] = '*(a\\|', ['ᾌ'] = '*)/a|', ['ᾍ'] = '*(/a|', ['ᾎ'] = '*)a=|', ['ᾏ'] = '*(a=|',
['β'] = 'b', ['Β'] = '*b', ['γ'] = 'g', ['Γ'] = '*g', ['δ'] = 'd', ['Δ'] = '*d',
['ε'] = 'e', ['έ'] = 'e/', ['ὲ'] = 'e\\', ['ἐ'] = 'e)', ['ἑ'] = 'e(',
['ἒ'] = 'e)\\', ['ἓ'] = 'e(\\', ['ἔ'] = 'e)/', ['ἕ'] = 'e(/',
['Ε'] = '*e', ['Έ'] = '*/e', ['Ὲ'] = '*\\e', ['Ἐ'] = '*)e', ['Ἑ'] = '*(e',
['Ἒ'] = '*)\\e', ['Ἓ'] = '*(\\e', ['Ἔ'] = '*)/e', ['Ἕ'] = '*(/e',
['ζ'] = 'z', ['Ζ'] = '*z',
['η'] = 'h', ['ή'] = 'h/', ['ὴ'] = 'h\\', ['ῆ'] = 'h=', ['ἠ'] = 'h)', ['ἡ'] = 'h(',
['ἢ'] = 'h)\\', ['ἣ'] = 'h(\\', ['ἤ'] = 'h)/', ['ἥ'] = 'h(/', ['ἦ'] = 'h)=', ['ἧ'] = 'h(=',
['ῃ'] = 'h|', ['ῄ'] = 'h/|', ['ῂ'] = 'h\\|', ['ῇ'] = 'h=|', ['ᾐ'] = 'h)|', ['ᾑ'] = 'h(|',
['ᾒ'] = 'h)\\|', ['ᾓ'] = 'h(\\|', ['ᾔ'] = 'h)/|', ['ᾕ'] = 'h(/|', ['ᾖ'] = 'h)=|', ['ᾗ'] = 'h(=|',
['Η'] = '*h', ['Ή'] = '*h/', ['Ὴ'] = '*h\\', ['Ἠ'] = '*)h', ['Ἡ'] = '*(h',
['Ἢ'] = '*)h\\', ['Ἣ'] = '*(h\\', ['Ἤ'] = '*)/h', ['Ἥ'] = '*(/h', ['Ἦ'] = '*)h=', ['Ἧ'] = '*(h=',
['ῌ'] = '*h|', ['ᾘ'] = '*)h|', ['ᾙ'] = '*(h|',
['ᾚ'] = '*)h\\|', ['ᾛ'] = '*(h\\|', ['ᾜ'] = '*)/h|', ['ᾝ'] = '*(/h|', ['ᾞ'] = '*)h=|', ['ᾟ'] = '*(h=|',
['θ'] = 'q', ['Θ'] = '*q',
['ῐ'] = 'i^', ['ῑ'] = 'i_', ['ϊ'] = 'i%252B', ['ῒ'] = 'i\\%252B', ['ΐ'] = 'i/%252B', ['ῖ'] = 'i=', ['ῗ'] = 'i=%252B',
['ι'] = 'i', ['ί'] = 'i/', ['ὶ'] = 'i\\', ['ἰ'] = 'i)', ['ἱ'] = 'i(',
['ἲ'] = 'i)\\', ['ἳ'] = 'i(\\', ['ἴ'] = 'i)/', ['ἵ'] = 'i(/', ['ἶ'] = 'i)=', ['ἷ'] = 'i(=',
['Ῐ'] = '*i^', ['Ῑ'] = '*i_', ['Ϊ'] = '*i%252B',
['Ι'] = '*i', ['Ί'] = '*i/', ['Ὶ'] = '*i\\', ['Ἰ'] = '*)i', ['Ἱ'] = '*(i',
['Ἲ'] = '*)i\\', ['Ἳ'] = '*(i\\', ['Ἴ'] = '*)/i', ['Ἵ'] = '*(/i', ['Ἶ'] = '*)i=', ['Ἷ'] = '*(i=',
['κ'] = 'k', ['Κ'] = '*k', ['λ'] = 'l', ['Λ'] = '*l',
['μ'] = 'm', ['Μ'] = '*m', ['ν'] = 'n', ['Ν'] = '*n', ['ξ'] = 'c', ['Ξ'] = '*c',
['ο'] = 'o', ['ό'] = 'o/', ['ὸ'] = 'o\\', ['ὀ'] = 'o)', ['ὁ'] = 'o(',
['ὂ'] = 'o)\\', ['ὃ'] = 'o(\\', ['ὄ'] = 'o)/', ['ὅ'] = 'o(/',
['Ο'] = '*o', ['Ό'] = '*/o', ['Ὸ'] = '*o\\', ['Ὀ'] = '*)o', ['Ὁ'] = '*(o',
['Ὂ'] = '*)o\\', ['Ὃ'] = '*(o\\', ['Ὄ'] = '*)/o', ['Ὅ'] = '*(/o',
['π'] = 'p', ['Π'] = '*p',
['ρ'] = 'r', ['ῤ'] = 'r)', ['ῥ'] = 'r(', ['ϱ'] = 'r', ['Ρ'] = '*r', ['Ῥ'] = '*(r',
['σ'] = 's', ['Σ'] = '*s', ['ς'] = 's',
['τ'] = 't', ['Τ'] = '*t',
['ῠ'] = 'u^', ['ῡ'] = 'u_', ['ϋ'] = 'u%252B', ['ΰ'] = 'u/%252B', ['ῢ'] = 'u\\%252B', ['ῧ'] = 'u=%252B',
['υ'] = 'u', ['ύ'] = 'u/', ['ὺ'] = 'u\\', ['ῦ'] = 'u=', ['ὐ'] = 'u)', ['ὑ'] = 'u(',
['ὒ'] = 'u)\\', ['ὓ'] = 'u(\\', ['ὔ'] = 'u)/', ['ὕ'] = 'u(/', ['ὖ'] = 'u)=', ['ὗ'] = 'u(=',
['Ῠ'] = '*u^', ['Ῡ'] = '*u_', ['Ϋ'] = '*u%252B',
['Υ'] = '*u', ['Ύ'] = '*/u', ['Ὺ'] = '*u\\', ['Ὑ'] = '*(u',
['Ὓ'] = '*(u\\', ['Ὕ'] = '*(u/', ['Ὗ'] = '*(u=',
['φ'] = 'f', ['ψ'] = 'y', ['Ψ'] = '*y', ['Φ'] = '*f', ['χ'] = 'x', ['Χ'] = '*x',
['ω'] = 'w', ['ώ'] = 'w/', ['ὼ'] = 'w\\', ['ῶ'] = 'w=', ['ὠ'] = 'w)', ['ὡ'] = 'w(',
['ὢ'] = 'w)\\', ['ὣ'] = 'w(\\', ['ὤ'] = 'w)/', ['ὥ'] = 'w(/', ['ὦ'] = 'w)=', ['ὧ'] = 'w(=',
['ῳ'] = 'w|', ['ῴ'] = 'w/|', ['ῲ'] = 'w\\|', ['ῷ'] = 'w=|', ['ᾠ'] = 'w)|', ['ᾡ'] = 'w(|',
['ᾢ'] = 'w)\\|', ['ᾣ'] = 'w(\\|', ['ᾤ'] = 'w)/|', ['ᾥ'] = 'w(/|', ['ᾦ'] = 'w)=|', ['ᾧ'] = 'w(=|',
['Ω'] = '*w', ['Ώ'] = '*/w', ['Ὼ'] = '*w\\', ['Ὠ'] = '*)w', ['Ὡ'] = '*(w',
['Ὢ'] = '*)w\\', ['Ὣ'] = '*(w\\', ['Ὤ'] = '*)w/', ['Ὥ'] = '*(/w', ['Ὦ'] = '*)w=', ['Ὧ'] = '*(w=',
['ῼ'] = '*w|', ['ᾨ'] = '*)w|', ['ᾩ'] = '*(w|',
['ᾪ'] = '*)w\\|', ['ᾫ'] = '*(w\\|', ['ᾬ'] = '*)/w|', ['ᾭ'] = '*(/w|', ['ᾮ'] = '*)w=|', ['ᾯ'] = '*(w=|',
['ϝ'] = 'v', ['Ϝ'] = '*v',
}
local text, _ = string.gsub(w, '[%z\1-\127\194-\244][\128-\191]*', chart) -- UTF-8 character pattern
return text
end
--- Converts an ancient greek word into its betacode.
--- frame.args[1] (string): The word.
--- @return string The betacode.
function p.betacode(frame)
local args = m_params.process(frame.args, {
[1] = { required = true },
})
return p._betacode(args[1])
end
return p