Module:pine-noun: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 5: | Line 5: | ||
local m_t = require('Module:table') | local m_t = require('Module:table') | ||
local m_pron = require('Module:pine-pron') | local m_pron = require('Module:pine-pron') | ||
local m_data = require('Module:pine-noun/data') | |||
local lang = require('Module:languages').getByCode("pine") | local lang = require('Module:languages').getByCode("pine") | ||
| Line 59: | Line 60: | ||
end | end | ||
local function detect_decl(word) | 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 65: | Line 66: | ||
local syllables = split(syllabified, "·") | local syllables = split(syllabified, "·") | ||
local | local syll_count = #syllables | ||
local stressed_syllable = syllables[1] | local stressed_syllable = syllables[1] | ||
local last_syllable = syllables[syll_count] | |||
if | local nucleus = match(stressed_syllable, "^" .. consonants .. "*(" .. vowels .. "+)") | ||
-- monosyllabic | local last_vowel = match(last_syllable, "(" .. vowels .. "+)$") -- nil if consonant-final | ||
if syll_count == 1 then | |||
nucleus = sub(nucleus, 1, 1) | |||
if last_vowel then | |||
last_vowel = sub(last_vowel, -1, -1) | |||
end | |||
end | |||
local polarity = {front, back} | |||
local pol_nucleus = quality_lookup(nucleus, polarity) | |||
local pol_last = quality_lookup(last_vowel, polarity) | |||
local phonicity = not last_vowel and "consonantal" or pol_nucleus == pol_last and "symphonic" or "antiphonic" | |||
if m_data.teleutophonic_ending(word) then | |||
return "teleutophonic-" .. teleuphonic_ending | |||
elseif syll_count == 1 then | |||
-- "There is unfortunately no way to tell whether a monosyllabic noun ending in a consonant belongs to | |||
-- the consonantal declension group of the schizaphonic declension group" (p. 119) | |||
if phoniticy == "consonantal" then | |||
if args.schiz ~= nil then | |||
return "monosyllabic-" .. (args.schiz .. "schizophonic" or "consonantal") | |||
else | |||
error(word .. " is a monosyllabic noun ending in a consonant. Disambiguation needed between consonantal and schizophonic declensions.") | |||
end | |||
end | |||
else | else | ||
local onset = match(stressed_syllable, "^" .. consonants .. "+") -- nil if vowel-initial | local onset = match(stressed_syllable, "^" .. consonants .. "+") -- nil if vowel-initial | ||
local coda = match(stressed_syllable, consonants .. "$") or match(syllables[2], "^" .. consonants .. "+") | local coda = match(stressed_syllable, consonants .. "$") or match(syllables[2], "^" .. consonants .. "+") | ||
| Line 82: | Line 107: | ||
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 | ||
Revision as of 13:53, 27 November 2025
- The following documentation is located at Module:pine-noun/doc.[edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
local export = {}
local m_u = require('Module:utilities')
local m_l = require('Module:links')
local m_t = require('Module:table')
local m_pron = require('Module:pine-pron')
local m_data = require('Module:pine-noun/data')
local lang = require('Module:languages').getByCode("pine")
local sub = mw.ustring.sub
local find = mw.ustring.find
local match = mw.ustring.match
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 PAGENAME = mw.title.getCurrentTitle().text
local NAMESPACE = mw.title.getCurrentTitle().nsText
local vowels = "aeiouyůảẻỉỏủỷ"
local consonants = "[rṛtpsṡdḍgġhḥkḳlḷƛvbnṇmṃ]"
local labial = m_t.listToSet({
"m", "ṃ", "p", "b", "v"
}, "labial")
local coronal = m_t.listToSet({
"t", "d", "ḍ", "s", "ṡ", "r", "ṛ", "l", "ḷ", "ƛ", "n", "ṇ",
"ts", "tṡ", "lį", "ḷį", "nį", "ṇį", "dn", "ng", "kn"
}, "coronal")
local dorsal = m_t.listToSet({
"k", "g", "ġ", "h", "ḥ",
"hį", "kṇ", "tġ"
}, "dorsal")
local front = m_t.listToSet({
"e", "i", "ů", "y", "ả", "ẻ", "ỉ", "ỷ",
"ai",
}, "front")
local back = m_t.listToSet({
"a", "o", "u", "ỏ", "ủ",
"oa", "oi",
}, "back")
local function quality_lookup(segment, tables)
if not segment then return nil end
for _, tbl in ipairs(poas) do
if tbl[segment] then return tbl[segment] end
end
-- fallback to first letter
local first = segment:sub(1,1)
for _, tbl in ipairs(poas) do
if tbl[first] then return tbl[first] end
end
end
local function detect_decl(word, args)
local syllabified = m_pron.syllabify_from_spelling(word)
--syllabified = gsub(syllabified, "·(" .. consonants .. ")%1", "%1·%1")
--syllabified = gsub(syllabified, "t·(t[sṡ])", "%1·%1")
local syllables = split(syllabified, "·")
local syll_count = #syllables
local stressed_syllable = syllables[1]
local last_syllable = syllables[syll_count]
local nucleus = match(stressed_syllable, "^" .. consonants .. "*(" .. vowels .. "+)")
local last_vowel = match(last_syllable, "(" .. vowels .. "+)$") -- nil if consonant-final
if syll_count == 1 then
nucleus = sub(nucleus, 1, 1)
if last_vowel then
last_vowel = sub(last_vowel, -1, -1)
end
end
local polarity = {front, back}
local pol_nucleus = quality_lookup(nucleus, polarity)
local pol_last = quality_lookup(last_vowel, polarity)
local phonicity = not last_vowel and "consonantal" or pol_nucleus == pol_last and "symphonic" or "antiphonic"
if m_data.teleutophonic_ending(word) then
return "teleutophonic-" .. teleuphonic_ending
elseif syll_count == 1 then
-- "There is unfortunately no way to tell whether a monosyllabic noun ending in a consonant belongs to
-- the consonantal declension group of the schizaphonic declension group" (p. 119)
if phoniticy == "consonantal" then
if args.schiz ~= nil then
return "monosyllabic-" .. (args.schiz .. "schizophonic" or "consonantal")
else
error(word .. " is a monosyllabic noun ending in a consonant. Disambiguation needed between consonantal and schizophonic declensions.")
end
end
else
local onset = match(stressed_syllable, "^" .. consonants .. "+") -- nil if vowel-initial
local coda = match(stressed_syllable, consonants .. "$") or match(syllables[2], "^" .. consonants .. "+")
local poas = {labial, coronal, dorsal}
local poa_onset = quality_lookup(onset, poas)
local poa_coda = quality_lookup(coda, poas)
local aphonicity = onset and "archeaphonic" or "enteraphonic"
local organicity = poa_onset and (poa_onset == poa_coda and "homorganic" or "heterorganic") or nil
end
end
-- The main entry point.
function export.show(frame)
local parent_args = frame:getParent().args
-- make the table
return make_table(data)
end
local function make_table(data)
end
return export