Module:id-headword/sandbox

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


local export = {}
local pos_functions = {}

local lang = require("Module:languages").getByCode("id")

-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.show(frame)
	local iparams = {
		 = {required = true},
	}
	local iargs = require("Module:parameters").process(frame.args, iparams)
	local args = frame:getParent().args
	local poscat = iargs

	local parargs = frame:getParent().args

	local params = {
		 = {list = true, disallow_holes = true},
		 = true,
		 = true,
		 = {type = "boolean"},
		 = {type = "boolean"},
		 = true, -- for testing
	}

	if pos_functions then
		local posparams = pos_functions.params
		if type(posparams) == "function" then
			posparams = posparams(lang)
		end
		for key, val in pairs(posparams) do
			params = val
		end
	end

    local args = require("Module:parameters").process(parargs, params)

	local pagename = args.pagename or mw.title.getCurrentTitle().text

	local user_specified_heads = args.head
	local heads = user_specified_heads
	if args.nolinkhead then
		if #heads == 0 then
			heads = {pagename}
		end
	end

	for i, head in ipairs(heads) do
		if head == "+" or head == "*" then
			head = nil
		end
		heads = {
			term = head,
			tr = "-",
		}
	end

	local data = {
		lang = lang,
		pos_category = poscat,
		categories = {},
		heads = heads,
		user_specified_heads = user_specified_heads,
		no_redundant_head_cat = #user_specified_heads == 0,
		inflections = {},
		pagename = pagename,
		id = args.id,
		sort_key = args.sort,
		force_cat_output = force_cat,
		is_suffix = false,
	}

	if pagename:find("^%-") and poscat ~= "suffix forms" then
		data.is_suffix = true
		data.pos_category = "suffixes"
		table.insert(data.categories, langname .. " " .. singular_poscat .. "-forming suffixes")
		table.insert(data.inflections, {label = singular_poscat .. "-forming suffix"})
	end

    if pos_functions and pos_functions.func then
        pos_functions.func(args, data)
    end

    if args.json then
        return require("Module:JSON").toJSON(data)
    end
	
    return require("Module:headword").full_headword(data)
end

-- Function for nouns (common and proper)

local function make_default_plural(pagename)
	-- Auto-detect full reduplication
	if pagename:match("^(+)%-%1$") then
		return "]"
	end

	local subwords = mw.text.split(pagename, "%s")
	local firstword = subwords
	subwords = mw.ustring.gsub("]-]", "(+%-)%1%1", "banyak %1")
	return table.concat(subwords, " ")
end

-- Shortcuts for the plural markings
pos_functions = {
	params = {
		 = {list = "pl"},
		 = {alias_of = 1, list = false},
	},
	func = function(args, data)
		-- Main code for noun plurality

		local pl1 = args
		-- Unknown or uncertain and requests
		if pl1 == "req" then
			table.insert(data.categories, "Requests for plural forms in Indonesian entries")
		elseif pl1 == "?" then
			table.insert(data.categories, "Indonesian nouns with unknown or uncertain plurals")
		
		-- Uncountable and semi-countable
		elseif pl1 == "-" then
			table.insert(data.categories, "Indonesian uncountable nouns")
			table.insert(data.inflections, {label = "]"})
		elseif pl1 == "0" then
			table.insert(data.categories, "Indonesian uncountable nouns")
		elseif pl1 == "u" then
			local pl_countable = {label = "usually ]"}
			local pl_plural = {label = "plural"}
			table.insert(data.categories, "Indonesian countable nouns")
			table.insert(data.categories, "Indonesian uncountable nouns")
			table.insert(pl_plural, make_default_plural(data.pagename))
			table.insert(data.inflections, pl_countable)
			table.insert(data.inflections, pl_plural)
		elseif pl1 == "~" then
			local pl_countable = {label = "] and ]"}
			local pl_plural = {label = "plural"}
			table.insert(data.categories, "Indonesian countable nouns")
			table.insert(data.categories, "Indonesian uncountable nouns")
			table.insert(pl_plural, make_default_plural(data.pagename))
			table.insert(data.inflections, pl_countable)
			table.insert(data.inflections, pl_plural)
		elseif pl1 == "pt" or pl1 == "p" then
			table.insert(data.categories, "Indonesian pluralia tantum")
			table.insert(data.inflections, {label = "]"})
		elseif pl1 == "st" or pl1 == "s" then
			table.insert(data.categories, "Indonesian singularia tantum")
			table.insert(data.inflections, {label = "]"})
		elseif pl1 == "1" then
			error("The parameter |pl=1 is invalid. Please specify the plurality with an existing value.")
		else
			-- Countable
			local pl = {label = "plural"}
			if not pl1 or pl1 == "+" then
				table.insert(pl, make_default_plural(data.pagename))
			elseif pl1 == "a" then
				table.insert(pl, make_default_plural(data.pagename))
				table.insert(pl, "] " .. data.pagename)
			elseif pl1 == "*" then
				table.insert(pl, data.pagename)
	        elseif pl1 == "*+" then
				table.insert(pl, data.pagename)
				table.insert(pl, make_default_plural(data.pagename))
			else
				table.insert(pl, pl1)
			end
			for i = 2, #args do
				table.insert(pl, args)
			end
			table.insert(data.inflections, pl)
		end
		
		if args then -- Only for tracking purpose
			require("Module:debug/track")("id-noun/pl2")
		end
		if args then -- Only for tracking purpose
			require("Module:debug/track")("id-noun/pl3")
		end
	end
}

pos_functions = {
  params = {
           = { list = true },
    active    = { list = true },
    passive   = { list = true },
  },
  func = function(args, data)
  local base = data.pagename

  local generate_passive = false

  if args and args == "+" then
    -- Default generation for both
    local active_form  = "me" .. base
    local passive_form = "di" .. base

    -- Count vowels
    local vowel_count = 0
    for _ in mw.ustring.gmatch(base, "") do
      vowel_count = vowel_count + 1
      if vowel_count > 1 then break end
    end

    if vowel_count == 1 then
      active_form = "menge" .. base
    else
      local first_two = mw.ustring.sub(base, 1, 2)
      local first     = mw.ustring.sub(base, 1, 1)

      if first_two == "sy" then
        active_form = "men"  .. base
      elseif first_two == "kh" then
        active_form = "meng" .. base
      elseif first == "k" then
        active_form = "meng" .. mw.ustring.sub(base, 2)
      elseif first == "t" then
        active_form = "men"  .. mw.ustring.sub(base, 2)
      elseif first == "s" then
        active_form = "meny" .. mw.ustring.sub(base, 2)
      elseif first == "p" then
        active_form = "mem"  .. mw.ustring.sub(base, 2)
      elseif first:match("") then
        active_form = "men"  .. base
      elseif first:match("") then
        active_form = "mem"  .. base
      elseif first:match("") then
        active_form = "meng" .. base
      elseif first:match("") then
        active_form = "meng" .. base
      end
    end

    args.active  = { active_form }
    args.passive = { passive_form }

  else
    -- If only active is specified, still generate passive
    if args.active and args.active and (not args.passive or not args.passive) then
      args.passive = { "di" .. base }
    end
  end

  -- Emit inflections
  if args.active and args.active then
    args.active.label = "active"
    table.insert(data.inflections, args.active)
  end
  if args.passive and args.passive then
    args.passive.label = "passive"
    table.insert(data.inflections, args.passive)
  end
end,
}

-- Build default periphrastic forms for adjectives
local function make_default_adj_forms(base)
  local comp = "] "  .. base
  local sup  = "] " .. base
  local eq   = "]"      .. base
  return comp, sup, eq
end

pos_functions = {
  params = {
               = { list = true },            -- allow |~|, |-|, |?|, |+|
    comparative   = { alias_of = 1, list = false },           -- named |comparative=…|
    superlative   = { list = true },            -- named |superlative=…|
    s             = { alias_of = "superlative", list = false },-- allow |s=…|
    equative      = { list = true },            -- named |equative=…|
    e             = { alias_of = "equative", list = false },  -- allow |e=…|
  },
  func = function(args, data)
    local base     = data.pagename
    local first    = mw.ustring.sub(base, 1, 1)
    local comp_raw = args    and args   -- the raw pos-1 marker
    local sup_raw  = args.superlative and args.superlative
    local eq_raw   = args.equative    and args.equative

    -- 1) “?” → no inflections, but add request category and stop.
    if comp_raw == "?" then
      table.insert(data.categories,
        "Requests for inflections in Indonesian adjective entries")
      return
    end

    -- 2) “-” → just “not comparable” and stop.
    if comp_raw == "-" then
      table.insert(data.inflections, { label = "]" })
      table.insert(data.categories, "Indonesian uncomparable adjectives")
      return
    end

    -- 3) “~” → insert the note, but then fall through to normal comp/sup.
    if comp_raw == "~" then
      table.insert(data.inflections, { label = "generally ]" })
      -- clear it so our next block treats it like “nothing given”
      comp_raw = nil
    end

    -- build the three periphrastic defaults
    local def_comp = "] "  .. base
    local def_sup  = "] " .. base
    -- equative is non-periphrastic “seBASE”
    local def_eq   = "se"           .. base

    -- 4) Comparative: always show (default when comp_raw==nil or comp_raw=="+")
    if comp_raw == nil or comp_raw == "+" then
      args.comparative = { def_comp }
    end

    -- 5) Superlative:
    if sup_raw == nil then
      -- default periphrastic only
      args.superlative = { def_sup }
    elseif sup_raw == "+" then
      -- both periphrastic + morphological
      local morph = (first == "r") and "te" or "ter"
      args.superlative = { def_sup, morph .. base }
    else
      -- user custom superlative stays as-is
    end

    -- 6) Equative: only when explicit e=+
    if eq_raw == "+" then
      args.equative = { def_eq }
    else
      args.equative = nil
    end

    -- 7) emit in order
    if args.comparative  and args.comparative then
      args.comparative.label = "]"
      table.insert(data.inflections, args.comparative)
    end
    if args.superlative  and args.superlative then
      args.superlative.label = "]"
      table.insert(data.inflections, args.superlative)
    end  
    if args.equative     and args.equative then
      args.equative.label = "]"
      table.insert(data.inflections, args.equative)
    end
  end,
}

return export