Module:siwa-noun: Difference between revisions
No edit summary |
No edit summary |
||
| Line 15: | Line 15: | ||
local PAGENAME = mw.title.getCurrentTitle().text | local PAGENAME = mw.title.getCurrentTitle().text | ||
-- | local HOOK = u(0x0309) -- COMBINING HOOK ABOVE ̉ | ||
local vowels = "[aeiouyůõảẻỉỏủỷęȯởử]" | |||
local consonants = "[mpbvntdsṡʦʨʥŋɲcɟħðrṁṅḥkgġhłƛɬḍ]" | local consonants = "[mpbvntdsṡʦʨʥŋɲcɟħðrṁṅḥkgġhłƛɬḍ]" | ||
local function | local function dedigraphicize(word) | ||
for digraph, repl in pairs(m_com.digraphs_to_single) do | for digraph, repl in pairs(m_com.digraphs_to_single) do | ||
word = gsub(word, digraph, repl) | word = gsub(word, digraph, repl) | ||
end | end | ||
return word | return word | ||
end | end | ||
function syll_count(word) | local function syll_count(word) | ||
word = dedigraphicize(word) | |||
local pattern = "(" .. consonants .. "?" .. vowels .. "+ː?" .. consonants .. "*)" | local pattern = "(" .. consonants .. "?" .. vowels .. "+ː?" .. consonants .. "*)" | ||
local | local _, n = gsub(word, pattern, "%1") | ||
return | return n | ||
end | end | ||
local function | local function detect_quality(word, stressed) | ||
local n = syll_count(word) | |||
if match(stressed, vowels .. vowels .. vowels .. "?") or match(mw.ustring.toNFD(stressed), HOOK) or n>=3 then | |||
local | |||
if match(stressed, vowels .. vowels .. vowels .. "?") or match(stressed, | |||
return "w" -- weak nouns | return "w" -- weak nouns | ||
elseif (match(stressed, vowels .. vowels .. vowels .. "?") or match(stressed, | elseif (match(stressed, vowels .. vowels .. vowels .. "?") or match(mw.ustring.toNFD(stressed), HOOK)) and n<3 then | ||
return "l" -- long nouns | return "l" -- long nouns | ||
else return "s" -- strong nouns | else return "s" -- strong nouns | ||
| Line 53: | Line 46: | ||
end | end | ||
local function detect_decl(word, | local function detect_decl(word, stressed) | ||
for og, repl in pairs(m_com.stressed_vowels) do | |||
local decl = gsub(stressed, og, repl) | |||
for | end | ||
end | return decl | ||
end | end | ||
| Line 77: | Line 62: | ||
local i, j = find(word, c) | local i, j = find(word, c) | ||
return sub(word, 1, i-1) .. lenited .. sub(word, j+1) | return sub(word, 1, i-1) .. lenited .. sub(word, j+1) | ||
end | end | ||