Module:siwa-noun: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 34: | Line 34: | ||
term = m_pron.crux(term, true, false, false) | term = m_pron.crux(term, true, false, false) | ||
local xc = "[mnɲŋpbtdcɟkɡvðsɕzʑxɣhrlɬjw⁽ʰ⁾ʔː̥͡"..UNRELEASED.."]" | local xc = "[mnɲŋpbtdcɟkɡvðsɕzʑxɣhrlɬjw⁽ʰ⁾ʔː̥͡"..UNRELEASED.."]" | ||
local pattern = | local pattern = xc .. "?(" .. vowels .. "+ː?)" .. xc .. "*" | ||
return gsub(term, pattern, "%1") | return gsub(term, pattern, "%1") | ||
| Line 41: | Line 41: | ||
local function detect_quality(word) | local function detect_quality(word) | ||
local stressed, n = syll_count(word) | local stressed, n = syll_count(word) | ||
if find(stressed, vowels .. vowels .. vowels .. "?") or find(stressed, | if find(stressed, vowels .. vowels .. vowels .. "?") or find(stressed, "ː") or n>=3 then | ||
return "w" -- weak nouns | return "w" -- weak nouns | ||
else return "s" -- strong nouns | else return "s" -- strong nouns | ||
| Line 47: | Line 47: | ||
end | end | ||
local function detect_decl(word, | local function detect_decl(word, gender, quality) | ||
if | local stressed = syll_count(word) | ||
local decl = | if gender and quality then | ||
local decl = gender .. "-" .. quality | |||
end | end | ||
end | end | ||
| Line 59: | Line 60: | ||
[1] = { required = true }, | [1] = { required = true }, | ||
[2] = { default = pagename }, | [2] = { default = pagename }, | ||
[3] = { default = detect_quality(word) }, | |||
} | } | ||
| Line 64: | Line 66: | ||
local sv = nil | local sv = nil | ||
local decl_type = {} | local decl_type = {} | ||
local word = args[2] | local gender, word, quality = args[1], args[2], args[3] | ||
local prefix = sub(pagename, 1, -(#word+1)) | local prefix = sub(pagename, 1, -(#word+1)) | ||
return | return gender .. " " .. word .. " " .. quality | ||
end | end | ||
return export | return export | ||
Revision as of 19:58, 4 February 2021
- The following documentation is located at Module:siwa-noun/doc.[edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
local export = {}
local m_u = require('Module:utilities')
local m_pron = require('Module:siwa-pron')
--local m_data = require('Module:siwa-noun/data')
local sub = mw.ustring.sub
local find = mw.ustring.find
local gmatch = mw.ustring.gmatch
local gsub = mw.ustring.gsub
local u = mw.ustring.char
local split = mw.text.split
local gsplit = mw.text.gsplit
local UNRELEASED = u(0x031A) -- COMBINING LEFT ANGLE ABOVE. ̚
local vowels = "[iɪyeøɛœæauɔ̃ɑʊ]"
local pagename = mw.title.getCurrentTitle().text
local stressedvowels = {
["ả"] = "a", ["a[ui]"] = "a", ["oa"] = "a", ["[eẻę]"] = "e", ["e[iu]"] = "e",
["ay"] = "e", ["[iỉ]"] = "i", ["i[aeou]"] = "i", ["[oỏõ]"] = "o", ["[oõ]u"] = "o",
["oi"] = "o", ["[uủ]"] = "u", ["u[oi]"] = "u", ["[yỷ]"] = "y", ["ů[ai]?"] = "y", ["ẻu"] = "y", ["ey"] = "y",
}
local lenition = {
["bb"] = "b", ["dd"] = "d", ["gg"] = "g", ["gį"] = "į", ["mm"] = "m", ["ll"] = "l", ["nn"] = "n",
["rr"] = "r", ["bġ"] = "p", ["pr"] = "p", ["dġ"] = "t", ["tr"] = "t", ["ḍb"] = "p", ["ḍḍ"] = "hh",
["ḍg"] = "k", ["bm"] = "m", ["dn"] = "n", ["kn"] = "ng", ["([lr])pp"] = "%1p", ["([lr])tt"] = "%1t", ["([lrms])kk"] = "%1k",
["k([lvs])"] = "g%1", ["ps"] = "bs", ["[vųbhḥg]"] = "", ["d[aoul]"] = "l", ["ġ[aou]"] = "vv", ["[dġ][eůy]"] = "", ["[rġ]i"] = "ṡi",
["di"] = "", ["nįi"] = "gįi", ["hhį"] = "ṡ", ["[ou]ų"] = "ů",
}
function syll_count(term)
term = m_pron.crux(term, true, false, false)
local xc = "[mnɲŋpbtdcɟkɡvðsɕzʑxɣhrlɬjw⁽ʰ⁾ʔː̥͡"..UNRELEASED.."]"
local pattern = xc .. "?(" .. vowels .. "+ː?)" .. xc .. "*"
return gsub(term, pattern, "%1")
end
local function detect_quality(word)
local stressed, n = syll_count(word)
if find(stressed, vowels .. vowels .. vowels .. "?") or find(stressed, "ː") or n>=3 then
return "w" -- weak nouns
else return "s" -- strong nouns
end -- long nouns are unpredictable, they will have to be inputted manually
end
local function detect_decl(word, gender, quality)
local stressed = syll_count(word)
if gender and quality then
local decl = gender .. "-" .. quality
end
end
-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.show(frame)
local params = {
[1] = { required = true },
[2] = { default = pagename },
[3] = { default = detect_quality(word) },
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local sv = nil
local decl_type = {}
local gender, word, quality = args[1], args[2], args[3]
local prefix = sub(pagename, 1, -(#word+1))
return gender .. " " .. word .. " " .. quality
end
return export