Module:ja-compound

Hello, you have come here looking for the meaning of the word Module:ja-compound. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:ja-compound, but we will also tell you about its etymology, its characteristics and you will know how to say Module:ja-compound in singular and plural. Everything you need to know about the word Module:ja-compound you have here. The definition of the word Module:ja-compound will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:ja-compound, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.

Used by Template:ja-compound. See there for details.

Requiring Module:parameters, Module:ja-link.


local export = {}

local link = require("Module:ja-link").link
-- ]

function export.show(frame)
	local args = require("Module:parameters").process(frame:getParent().args, {
		 = {list = true, allow_holes = true},
		 = {list = true, allow_holes = true},
		 = {list = true, allow_holes = true},
		 = {list = true, allow_holes = true},
		 = {list = true, allow_holes = true},
		 = {list = true, allow_holes = true},
		 = {list = true, allow_holes = true},
		 = {},
		 = {type = "boolean"},
		 = {type = "boolean"}, -- required for use with {{surf}} but ignored
	})
	local len = (args.maxindex + 1) / 2
	local result = {}
	local categories, sort = {"Japanese compound terms"}, {}

	local function format_label(labels)
		local labels_f = {}
		for lb in labels:gmatch"+" do
			local rl = ({
				 = {"]", "Japanese terms with rendaku"},
				 = {"]", "Japanese terms with renjō"},
			})
			if rl then
				table.insert(labels_f, rl)
				table.insert(categories, rl)
			else
				table.insert(labels_f, lb)
			end
		end
		return table.concat(labels_f, ", ") .. " form "
	end

	for i = 1, len do
		local kana_this = args or args
		local kana_this_raw = kana_this:gsub("", "")

		local b_pre, b_suf = kana_this:match"%-$", kana_this:match"^%-"
		local cat_form = args and args:gsub("", "") or kana_this_raw
		if b_pre then
			if b_suf then
				table.insert(categories, "Japanese terms infixed with " .. cat_form)
			else
				table.insert(categories, "Japanese terms prefixed with " .. cat_form)
			end
		elseif b_suf then table.insert(categories, "Japanese terms suffixed with " .. cat_form) end

		local data_pos
		if args.s then
			local sandhi_lemma, sandhi_kana, sandhi_label, _s
			_s, sandhi_label = args.s:match"^(.-)%?(.-)$"
			_s = _s or args.s
			sandhi_lemma, sandhi_kana = _s:match"^(.-):(.-)$"
			if sandhi_lemma == "" then
				sandhi_lemma = args
			elseif sandhi_lemma == nil then
				sandhi_lemma = _s
			end

			data_pos = table.concat{
				args and args .. ", " or "",
				sandhi_label and format_label(sandhi_label) or "as ",
				link{
					lemma = sandhi_lemma,
					kana = sandhi_kana,
					linkto = "-",
				},
			}
			table.insert(sort, ((sandhi_kana or sandhi_lemma):gsub("", "")))
		else
			data_pos = args
			table.insert(sort, (kana_this_raw:gsub("", "")))
		end
		table.insert(result, link{
			lemma = args,
			kana = args,
			gloss = args,
			transliteration = args,
			lit = args,
			linkto = args,
			pos = data_pos,
		})
	end
	result = table.concat(result, " + ")

	sort = args.sort or table.concat(sort)
	if args.nocat then
		categories = ""
	else
		local lang = require("Module:languages").getByCode("jp")
		categories = require("Module:utilities").format_categories(categories, lang, sort)
	end

	return result .. categories
end

return export