มอดูล:category tree/poscatboiler/data/สัมผัส
หน้าตา
- The following documentation is generated by Template:poscatboiler data submodule documentation. [edit]
- Useful links: root page • root page’s subpages • links • transclusions • testcases • sandbox
This data submodule defines part of Wiktionary's category structure.
For an introduction to the poscatboiler
system and a description of how to add or modify categories, see Module:category tree/poscatboiler/data/documentation.
local labels = {}
local raw_categories = {}
local raw_handlers = {}
-----------------------------------------------------------------------------
-- --
-- LABELS --
-- --
-----------------------------------------------------------------------------
labels["สัมผัส"] = {
description = "List of indexes of {{{langname}}} words by their rhymes.",
umbrella_parents = "มูลฐาน",
parents = {{name = "{{{langcat}}}", raw = true}},
}
labels["rhymes"] = labels["สัมผัส"]
labels["สัมผัสเอกเทศ"] = {
description = "Lists of {{{langname}}} words that don't rhyme with other words.",
umbrella_parents = "หมวดหมู่ย่อยของสัมผัสแบ่งตามภาษา",
parents = {"สัมผัส"},
}
labels["refractory rhymes"] = labels["สัมผัสเอกเทศ"]
-----------------------------------------------------------------------------
-- --
-- RAW CATEGORIES --
-- --
-----------------------------------------------------------------------------
raw_categories["หมวดหมู่ย่อยของสัมผัสแบ่งตามภาษา"] = {
description = "Umbrella categories covering topics related to rhymes.",
additional = "{{{umbrella_meta_msg}}}",
parents = {
"หมวดหมู่ใหญ่รวมหัวข้อ",
{name = "สัมผัส", is_label = true, sort = " "},
},
}
raw_categories["สัมผัส"] = {
description = "Umbrella categories covering rhymes by language.",
additional = "{{{umbrella_meta_msg}}}",
parents = {
"หมวดหมู่ใหญ่รวมหัวข้อ",
{name = "สัมผัส", is_label = true, sort = " "},
},
}
-----------------------------------------------------------------------------
-- --
-- RAW HANDLERS --
-- --
-----------------------------------------------------------------------------
table.insert(raw_handlers, function(data)
local function rhymeTopCategory(lang)
return {
lang = lang:getCode(),
description = "รายการศัพท์ภาษา" .. lang:makeCategoryLink() .. "แบ่งตามเสียงสัมผัส",
additional = "This is an umbrella category. It contains no dictionary entries, but rather possible rhymes as subcategories.",
parents = {
"{{{langcat}}}",
{name = "สัมผัส", sort = langname},
},
breadcrumb = "สัมผัส",
toctemplateprefix = "rhymetop"
}
end
local function linkRhymeIfExists(lang, rhyme) -- {{change new|Though this could be ported to Wikitionary}}
if mw.title.new('สัมผัส:' .. lang:getCategoryName() .. "/" .. rhyme).exists then
return "'''[[สัมผัส:" .. lang:getCategoryName() .. "/" .. rhyme ..'|<span class="IPA">-' .. rhyme .. "</span>]]'''"
end
return '<span class="IPA">-' .. rhyme .. '</span>'
end
local function rhymeCategory(lang, rhyme)
return {
lang = lang:getCode(),
description = "รายการศัพท์ภาษา" .. lang:makeCategoryLink() .. 'ที่มีเสียงสัมผัส ' .. linkRhymeIfExists(lang, rhyme),
parents = {
{name = "สัมผัส:" .. lang:getCategoryName(), sort = rhyme},
},
breadcrumb = '<span class="IPA">-' .. rhyme .. '</span>',
displaytitle = 'สัมผัส:' .. lang:getCategoryName() .. '/<span class="IPA">' .. rhyme .. '</span>'
}
end
local function rhymeSyllableCountCategory(lang, rhyme, syllableCount)
return {
lang = lang:getCode(),
description = "รายการศัพท์ภาษา" .. lang:makeCategoryLink() .. 'ที่มี ' .. syllableCount .. " พยางค์ และมีเสียงสัมผัส " .. linkRhymeIfExists(lang, rhyme),
parents = {
{name = "สัมผัส:" .. lang:getCategoryName() .. "/" .. rhyme, sort = syllableCount},
},
breadcrumb = tostring(syllableCount) .. " syllables",
displaytitle = 'สัมผัส:' .. lang:getCategoryName() .. '/<span class="IPA">' .. rhyme .. '</span>/' .. tostring(syllableCount) .. " พยางค์"
}
end
local langname = data.category:match("^สัมผัส:ภาษา([^/]+)")
if langname then
local lang = require("Module:languages").getByCanonicalName(langname)
if lang then
local tokens = mw.text.split(data.category, "/")
if #tokens > 1 then
local rhyme = tokens[2]
if #tokens == 3 then
-- rhyme + syllable count category
local syllables = nil
if tokens[3] == "1 พยางค์" then
syllables = 1
else
local syllablesregex = tokens[3]:match("(%d+) พยางค์")
if syllablesregex then
syllables = tonumber(syllablesregex)
if syllables < 2 then
syllables = nil
end
end
end
if syllables then
return rhymeSyllableCountCategory(lang, rhyme, syllables)
end
elseif #tokens == 2 then
-- rhyme category
return rhymeCategory(lang, rhyme)
end
else
-- rhyme language top category
return rhymeTopCategory(lang)
end
end
end
end)
return {LABELS = labels, RAW_CATEGORIES = raw_categories, RAW_HANDLERS = raw_handlers}