Module:pine-noun: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 2: Line 2:


local m_u = require('Module:utilities')
local m_u = require('Module:utilities')
local m_su = require('Module:string utilities')
local m_l = require('Module:links')
local m_l = require('Module:links')
local m_t = require('Module:table')
local m_t = require('Module:table')
Line 8: Line 9:
local lang = require('Module:languages').getByCode("pine")
local lang = require('Module:languages').getByCode("pine")


local sub = mw.ustring.sub
local sub = m_su.sub
local find = mw.ustring.find
local find = m_su.find
local match = mw.ustring.match
local match = m_su.match
local gmatch = mw.ustring.gmatch
local gmatch = m_su.gmatch
local gsub = mw.ustring.gsub
local gsub = m_su.gsub
local u = mw.ustring.char
local u = m_su.char
local split = mw.text.split
local split = m_su.split
local gsplit = mw.text.gsplit
local gsplit = m_su.gsplit
local len = mw.ustring.len
local len = m_su.len
local unpack = unpack or table.unpack -- Lua 5.2 compatibility


local PAGENAME = mw.loadData("Module:headword/data").pagename
local PAGENAME = mw.loadData("Module:headword/data").pagename
Line 55: Line 57:
     end
     end
     -- fallback to first letter
     -- fallback to first letter
     local first = segment:sub(1,1)
     local first = sub(segment,1,1)
     for _, tbl in ipairs(tables) do
     for _, tbl in ipairs(tables) do
         if tbl[first] then return tbl[first] end
         if tbl[first] then return tbl[first] end
Line 61: Line 63:
end
end


local function detect_decl(word, schiz)
local function detect_decl(word, args)
local syllabified = m_pron.syllabify_from_spelling(word)
local syllabified = m_pron.syllabify_from_spelling(word)
--syllabified = gsub(syllabified, "·(" .. consonants .. ")%1", "%1·%1")
--syllabified = gsub(syllabified, "·(" .. consonants .. ")%1", "%1·%1")
Line 85: Line 87:
local phonicity = not last_vowel and "consonantal" or pol_nucleus == pol_last and "symphonic" or "antiphonic"
local phonicity = not last_vowel and "consonantal" or pol_nucleus == pol_last and "symphonic" or "antiphonic"
if m_data.teleutophonic_ending(word) then
local teleutophonic_ending = m_data.teleutophonic_ending(word)
if teleutophonic_ending then
return "teleutophonic-" .. teleuphonic_ending
return "teleutophonic-" .. teleuphonic_ending
elseif syll_count == 1 then --monosyllabic
elseif syll_count == 1 then --monosyllabic
Line 91: Line 94:
-- the consonantal declension group of the schizaphonic declension group" (p. 119)
-- the consonantal declension group of the schizaphonic declension group" (p. 119)
if phonicity == "consonantal" then
if phonicity == "consonantal" then
if schiz == nil then
if args.schiz == nil then
error(word .. " is a monosyllabic noun ending in a consonant. Disambiguation is needed between consonantal and schizophonic declensions.")
error(word .. " is a monosyllabic noun ending in a consonant. Disambiguation is needed between consonantal and schizophonic declensions.")
else
else
return "monosyllabic-" .. (schiz and "schizaphonic" or "consonantal")
return "monosyllabic-" .. (args.schiz and "schizaphonic" or "consonantal")
end
end
else
else
Line 110: Line 113:
local organicity = poa_onset and (poa_onset == poa_coda and "homorganic" or "heterorganic") or nil
local organicity = poa_onset and (poa_onset == poa_coda and "homorganic" or "heterorganic") or nil
if syll_count == 2 then --bisyllabic
if syll_count == 2 or syll_count == 4 then -- bi- and polysyllabic (4)
return "bisyllabic-" .. (phonicity == "consonantal" and phonicity or aphonicity .. "-" .. (onset and organicity .. "-" or "") .. phonicity)
return "bisyllabic-" .. (phonicity == "consonantal" and phonicity or aphonicity .. "-" .. (onset and organicity .. "-" or "") .. phonicity)
elseif syll_count == 3 then --trisyllabic
elseif syll_count == 3 or syll_count >= 5 then -- trisyllabic and polysyllabic (5 or more)
local last_cluster = match(word, "(" .. consonants .. "+)" .. vowels .. "*t?$")
local asematic_endings = {
{ "ng", "n" }, { "[tbnṇmṃd]?[nṇmṃ]", "n" },
{ "[lḷƛ]", "l" },
{ "^[rṛ]", "r" },
{ "^ḍ", "ts" }, { "^tt?[sṡ]", "ts" },
{ "^[sh]", "s" },
{ "^[ġḥvį]", "ġ" },
}
local apocope = args.apo or "t" -- default to -t
if not args.apo then
for _, triggers_result in ipairs(spec) do
local triggers, result = unpack(triggers_result)
if match(last_cluster, triggers) then
apocope = result
end
end
end
return "trisyllabic-" .. ((phonicity == "consonantal" and not args.apo) and phonicity or "apocoptic-" .. apocope)
end
end
end
end
Line 176: Line 200:
["decl"] = {},
["decl"] = {},
["schiz"] = {type = "boolean"},
["schiz"] = {type = "boolean"},
["apo"] = {},
}
}


Navigation menu