Module:he-headword

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

This module is used to implement Hebrew headword-line templates. See an automatically generated list of the templates which it supports here.


local m_headword = require("Module:headword")
local com = require("Module:he-common")

local export = {}
local pos_functions = {}

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

local function get_params_list(args, argprefix)
	local export = {}
	i = 1
	term = argprefix

	while args ~= nil and args ~= "" do
		table.insert(export, term)

		i = i + 1
		term = argprefix .. i
	end
	return export
end

local function make_params_array(args, params)
	local export = {}
	for _, param in ipairs(params) do
		table.insert(export, args)
	end
	return export
end

local function maybe_get_inflection(args, name, params, list, accel, is_construct)
	if list then
		params = get_params_list(args, params)
	end
	
	local tbl = {}
	if type(params) ~= "table" then
		params = {params}
	end
	for _, param in ipairs(params) do
		local paramwv = param .. "wv"
		local paramdwv = param .. "dwv"
		if args or args or args then
			tbl.label = name
			tbl.accel = accel
			if is_construct == true then
				table.insert(tbl, com.gen_link_ending_with_makaf(args, args, args))
			else
				table.insert(tbl, com.gen_link(args, args, args))
			end
		end
		if args == "" or args == "" or args == "" then
			require('Module:debug').track("he-noun/empty-form-param")
		elseif args ~= nil and args ~= nil then
			require('Module:debug').track("he-noun/param-and-paramwv")
		end
	end
	return next(tbl) and tbl
end

-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.show(frame)
	local args = {}
	for k, v in pairs(frame:getParent().args) do
		if v ~= "" then
			args = v
		end
	end
	local poscat = frame.args or error("Part of speech has not been specified. Please pass parameter 1 to the module invocation.")
	
	if frame.args and (args == "" or not args) then args = frame.args end
	
	local data = {lang = lang, pos_category = poscat, categories = {}, heads = make_params_array(args, get_params_list(args, "head")), translits = make_params_array(args, get_params_list(args, "tr")), genders = {}, inflections = {}}
	local head = args; if head == "" then head = nil end; data.heads = head
	
	data.sort_key = args; if data.sort_key == "" then data.sort_key = nil end
	
	if data.sort_key then
		data.sort_key = data.sort_key .. "a" .. mw.title.getCurrentTitle().subpageText
	end
	
	local wv = args or mw.title.getCurrentTitle().subpageText
	local dwv = args
	
	if not data.heads then
		data.no_redundant_head_cat = true
		if dwv then
			data.heads = wv .. " / " .. '<span class="inflection-table">' .. "]" .. "</span>" -- not really an inflection table but for the black links
		else
			data.heads = wv
		end
	end
	
	if dwv and mw.ustring.match(dwv, "%[%[") then
		require('Module:debug').track("he-noun/link-in-dwv")
	end
	
	if not (args or args or args) then
		require('Module:debug').track("he-noun/no-nikud")
	end
	
	if mw.ustring.match(wv, "׳") then
		table.insert(data.categories, "Hebrew terms spelled with ׳")
	end
	
	if mw.ustring.match(wv, "״") then
		table.insert(data.categories, "Hebrew terms spelled with ״")
	end

	local begedkefet = "בגדכפת"
	local vowels = "ְֱֲֳִֵֶַָֹֻ"
	local begedkefet_regex = ""
	local vowels_with_mater_lectionis_regex = ""

	local fixed_nikud = com.fix_nikud(args or args or "")
	if args == "1" 
		or mw.ustring.match(fixed_nikud, "^" .. begedkefet_regex .. vowels_with_mater_lectionis_regex) then
		table.insert(data.categories, "Hebrew terms beginning with an unchangeable begedkefet letter")
	end

	local pattern_link = ""
	if args and args ~= "" and poscat ~= "verbs" then
		table.insert(data.categories, "Hebrew terms in the pattern " .. args)
		local patfmt = require("Module:links").full_link({lang = lang, alt = args, tr = "-"})
		pattern_link = " <small> .. "| ]]</small>"
	end

	if pos_functions then
		pos_functions(args, data, wv)
	end

	table.insert(data.inflections, maybe_get_inflection(args, "Biblical Hebrew ]", "pausal", false))
	
	return (m_headword.full_headword(data)) .. pattern_link
end

local final_to_nonfinal = {
	="כ",
	="מ",
	="נ",
	="פ",
	="צ",
}

local function stemify_helper(letter, rest)
	return (final_to_nonfinal or letter) .. rest
end

local function stemify(x)
	if x then
		x = mw.ustring.gsub(x, "ְ(*)$", "%1")
		x = mw.ustring.gsub(x, "()(*)$", stemify_helper)
	end
	return x
end

local function gen_fem_t(stemwv)
	local stub, vowel, final, dagesh = mw.ustring.match(com.fix_nikud(stemwv), "^(.*)()(?)(ּ?)$")
	if not stub then
		error("Error attaching feminine ת suffix, please check vocalization.")
	end
	if final == "י" then
		if vowel ~= "ִ" or dagesh ~= "ּ" then
			error("Error attaching feminine ת suffix, please check vocalization.")
		end
		return stub .. vowel .. final .. "ת"
	end
	if vowel == "ִ" or dagesh ~= "" then
		error("Error attaching feminine ת suffix, please check vocalization.")
	end
	if final == "א" then
		return stub .. "ֵ" .. final .. "ת"
	end
	if final == "ה" or final == "ח" or final == "ע" then
		return stub .. "ַ" .. final .. "ַ" .. "ת"
	end
	return stub .. "ֶ" .. final .. "ֶ" .. "ת"
end

pos_functions = function(args, data)
	-- table.insert(genders, "m")
	if args == nil or args == "" then
		-- Use only provided inflections
		table.insert(data.inflections, maybe_get_inflection(args, "feminine", {"f", "f2"}, false))
		table.insert(data.inflections, maybe_get_inflection(args, "masculine plural", {"mp", "mp2"}, false))
		table.insert(data.inflections, maybe_get_inflection(args, "feminine plural", "fp", true))
	else
		require("Module:debug").track("he-adj/auto")
		-- Automatically generate inflections
		local stem = args
		local stemwv = args
		local stemdwv = args
		local e = false
		if not stem then
			if stemwv then
				stem = com.remove_nikud(stemwv)
			else
				stem = stemify(mw.title.getCurrentTitle().subpageText)
				if not stemdwv then
					stemwv = stemify(args)
					stemdwv = stemify(args)
				end
				local fstemwv = stemwv and com.fix_nikud(stemwv)
				local fstemdwv = stemdwv and com.fix_nikud(stemdwv)
				if (fstemwv or fstemdwv) and (stem ~= nil or stem:match("ה$")) and (fstemwv == nil or fstemwv:match("ֶה$")) and (fstemdwv == nil or fstemdwv:match("ֶה$")) then
					e = true
					stem = stem and stem:gsub("ה$", "")
					stemwv = fstemwv and fstemwv:gsub("ֶה$", "")
					stemdwv = fstemdwv and fstemdwv:gsub("ֶה$", "")
				end
			end
		end
		stem, stemwv, stemdwv = com.process_wv_triad(stem, stemwv, stemdwv)
		local f, fwv, fdwv = com.process_wv_triad(args, args, args)
		local f2, f2wv, f2dwv = com.process_wv_triad(args, args, args)
		local mp, mpwv, mpdwv = com.process_wv_triad(args, args, args)
		local mp2, mp2wv, mp2dwv = com.process_wv_triad(args, args, args)
		local fp, fpwv, fpdwv = com.process_wv_triad(args, args, args)
		if f ~= "-" then
			if not (f or fwv or fdwv) then
				f = stem and (stem .. "ה")
				fwv = stemwv and (stemwv .. "ָה")
				fdwv = stemdwv and (stemdwv .. "ָה")
			elseif f == "ת" and not (fwv or fdwv) then
				f = stem and (stem .. (e and "ית" or "ת"))
				fwv = stemwv and (e and (stemwv .. "ֵית") or gen_fem_t(stemwv))
				fdwv = stemdwv and (e and (stemdwv .. "ֵית") or gen_fem_t(stemdwv))
			end
			if f2 == "ת" and not (f2wv or f2dwv) then
				f2 = stem and (stem .. (e and "ית" or "ת"))
				f2wv = stemwv and (e and (stemwv .. "ֵית") or gen_fem_t(stemwv))
				f2dwv = stemdwv and (e and (stemdwv .. "ֵית") or gen_fem_t(stemdwv))
			end
			tbl = {label = "feminine", com.gen_link(f, fwv, fdwv)}
			if f2 or f2wv or f2dwv then
				table.insert(tbl, com.gen_link(f2, f2wv, f2dwv))
			end
			table.insert(data.inflections, tbl)
		end
		if mp ~= "-" then
			if not (mp or mpwv or mpdwv) then
				mp = stem and (stem .. "ים")
				mpwv = stemwv and (stemwv .. "ִים")
				mpdwv = stemdwv and (stemdwv .. "ִים")
			end
			tbl = {label = "masculine plural", com.gen_link(mp, mpwv, mpdwv)}
			if mp2 or mp2wv or mp2dwv then
				table.insert(tbl, com.gen_link(mp2, mp2wv, mp2dwv))
			end
			table.insert(data.inflections, tbl)
		end
		if fp ~= "-" then
			if not (fp or fpwv or fpdwv) then
				fp = stem and (stem .. "ות")
				fpwv = stemwv and (stemwv .. "וֹת")
				fpdwv = stemdwv and (stemdwv .. "וֹת")
			end
			tbl = {label = "feminine plural", com.gen_link(fp, fpwv, fpdwv)}
			table.insert(data.inflections, tbl)
		end
	end
end

pos_functions = function(args, data, wv)
	if args == "m" or args == "m-p" then
		table.insert(data.genders, args)
		table.insert(data.genders, args)
		table.insert(data.inflections, maybe_get_inflection(args, "feminine counterpart", "f", true))
	elseif args == "f" or args == "f-p" then
		table.insert(data.genders, args)
		table.insert(data.genders, args)
		table.insert(data.inflections, maybe_get_inflection(args, "masculine counterpart", "m", false))
	end
end

local function validate_gender(gender, param)
	if not (
		gender == "" or gender == nil
		or gender == "m" or gender == "f"
		or gender == "m-d" or gender == "f-d"
		or gender == "m-p" or gender == "f-p"
		or gender == "-" -- for אַל "naught"
	) then
		if gender:find "m" and gender:find "f" then
			error("To indicate two genders, use |g2=; for instance, for masculine or feminine, |g=m|g2=f")
		else
			error("Gender in |" .. param .. "=" .. gender .. " is invalid; choose from m, f, m-d, f-d, m-p, f-p")
		end
	end
end

pos_functions = function(args, data, wv)
	validate_gender(args, "g")
	validate_gender(args, "g2")
	if args ~= nil and args ~= "" and not (args ~= nil and args ~= "") then
		error("|g= parameter required if |g2= is present")
	end
	
	if args == "m" or args == "f" then
		table.insert(data.genders, args)
		table.insert(data.genders, args)
		if args ~= nil then
			require('Module:debug').track("he-noun/sg-for-head")
		end
	elseif args == "m-d" or args == "f-d" then
		table.insert(data.genders, args)
		table.insert(data.genders, args)
		table.insert(data.categories, "Hebrew dualia tantum")
		table.insert(data.inflections, maybe_get_inflection(args, "singular indefinite", "sg", false))
	elseif args == "m-p" or args == "f-p" then
		table.insert(data.genders, args)
		table.insert(data.genders, args)
		table.insert(data.categories, "Hebrew pluralia tantum")
		table.insert(data.inflections, maybe_get_inflection(args, "singular indefinite", "sg", false))
	elseif args == "" or args == nil then
		table.insert(data.genders, "?")
		table.insert(data.categories, "Requests for gender in Hebrew entries")
	end
	
	-- Dual forms rare enough that there's no need for without/missing categoristion
	table.insert(data.inflections, maybe_get_inflection(args, "dual indefinite", "dual", true))
	
	-- Compound words such as בית קברות should be ignored when filling up categories like
	-- Category:Hebrew masculine nouns with plurals ending in ־ות
	is_compound_word = mw.ustring.find(wv, "") ~= nil

	if args == "-" then
		table.insert(data.inflections, {label = "no plural forms"})
		table.insert(data.categories, "Hebrew nouns without plural forms")
	elseif args == "" or args == nil then
		table.insert(data.categories, "Hebrew noun entries missing plural forms")
	else
		table.insert(data.inflections, maybe_get_inflection(args, "plural indefinite", "pl", true, {form = "p", lemma = wv}))
		if args == "m" and mw.ustring.sub(com.remove_nikud(args), -2, -1) == "ות" and not is_compound_word then
			table.insert(data.categories, "Hebrew masculine nouns with plurals ending in ־ות")
		elseif args == "f" and mw.ustring.sub(com.remove_nikud(args), -2, -1) == "ים" and not is_compound_word then
			table.insert(data.categories, "Hebrew feminine nouns with plurals ending in ־ים")
		end
		if mw.ustring.sub(com.remove_nikud(args), -3, -1) == "יים"
		and mw.ustring.sub(mw.ustring.gsub(com.remove_nikud(wv), "]", ""), -1, -1) ~= "י" then
			table.insert(data.categories, "Hebrew nouns with plurals ending in ־יים")
		end
	end

	if args == "-" then
		table.insert(data.inflections, {label = "no construct forms"})
		table.insert(data.categories, "Hebrew nouns without construct forms")
	else
		if args == "" or args == nil then
			table.insert(data.categories, "Hebrew noun entries missing singular construct forms")
		else
			table.insert(data.inflections, maybe_get_inflection(args, "singular construct", "cons", true, {form = "s|cons", lemma = wv}, true))
		end
		table.insert(data.inflections, maybe_get_inflection(args, "dual construct", "dualcons", true , nil, true))
		if (args == "" or args == nil) and args ~= "-" then
			table.insert(data.categories, "Hebrew noun entries missing plural construct forms")
		else
			table.insert(data.inflections, maybe_get_inflection(args, "plural construct", "plcons", true, {form = "p|cons", lemma = wv}, true))
		end
	end

	table.insert(data.inflections, maybe_get_inflection(args, "masculine counterpart", "m", true))
	table.insert(data.inflections, maybe_get_inflection(args, "feminine counterpart", "f", true))

	if args == "m" and mw.ustring.sub((com.remove_nikud(args or args or mw.title.getCurrentTitle().subpageText)), -1) == "ת" then
		table.insert(data.categories, "Hebrew masculine nouns ending in ־ת")
	elseif args == "m" and mw.ustring.sub((com.remove_nikud(args or args or mw.title.getCurrentTitle().subpageText)), -1) == "ה" then
		table.insert(data.categories, "Hebrew masculine nouns ending in ־ה")
	elseif args == "m" then
		table.insert(data.categories, "Hebrew masculine nouns")
	elseif args == "f" then
		table.insert(data.categories, "Hebrew feminine nouns")
	end
end

pos_functions = function(args, data)
	table.insert(data.inflections, maybe_get_inflection(args, "construct", "cons", true, nil, true))
	
	table.insert(data.inflections, maybe_get_inflection(args, "dual", "dual", true))
	table.insert(data.inflections, maybe_get_inflection(args, "plural", "pl", true))
	local f = maybe_get_inflection(args, "feminine", "f", true)
	table.insert(data.inflections, f)
	table.insert(data.inflections, maybe_get_inflection(args, "feminine construct", "fcons", true, nil, true))

	table.insert(data.genders, "m")
	if not f then
		table.insert(data.genders, "f")
	end
end

pos_functions = function(args, data)
	if args == "m" or args == "f" or args == "m-p" or args == "f-p" then
		table.insert(data.genders, args)
		table.insert(data.genders, args)
	elseif args then
		require('Module:debug').track("he-pron/param-n")
	end
end

pos_functions = function(args, data, wv)
	if args and args ~= "-" and args ~= "" then
		table.insert(data.inflections, maybe_get_inflection(args, "plural indefinite", "pl", true, {form = "p", lemma = wv}))
		if args == "m" and mw.ustring.sub(com.remove_nikud(args), -2, -1) == "ות" then
			table.insert(data.categories, "Hebrew masculine nouns with plurals ending in ־ות")
		elseif args == "f" and mw.ustring.sub(com.remove_nikud(args), -2, -1) == "ים" then
			table.insert(data.categories, "Hebrew feminine nouns with plurals ending in ־ים")
		end
		if mw.ustring.sub(com.remove_nikud(args), -3, -1) == "יים"
		and mw.ustring.sub(mw.ustring.gsub(com.remove_nikud(wv), "]", ""), -1, -1) ~= "י" then
			table.insert(data.categories, "Hebrew nouns with plurals ending in ־יים")
		end
	end

	if args == "m" or args == "f" then
		table.insert(data.genders, args)
		table.insert(data.genders, args)
	elseif args == "m-d" or args == "f-d" then
		table.insert(data.genders, args)
		table.insert(data.genders, args)
		table.insert(data.categories, "Hebrew dualia tantum")
	elseif args == "m-p" or args == "f-p" then
		table.insert(data.genders, args)
		table.insert(data.genders, args)
		table.insert(data.categories, "Hebrew pluralia tantum")
	elseif args == "" or args == nil then
		table.insert(data.categories, "Requests for gender in Hebrew entries")
	elseif args == "-" then --surnames don't really have gender
		table.insert(data.categories, "Hebrew proper nouns without gender")
	else
		table.insert(data.genders, "?")
	end
end

local binyanim = {
	 = "pa'al",
	 = "pi'el",
	 = "hif'il",
	 = "hitpa'el",
	 = "huf'al",
	 = "pu'al",
	 = "nif'al",
	 = "hitpu'al", -- should this be included?
}

local weakroots = {
	 = {
		 = true,
		 = true,
		 = true,
		 = true,
		 = true,
		 = true,
		 = true,
	},
	 = {
		 = true,
		 = true,
		 = true,
		 = true,
		 = true,
		 = true,
		 = true,
	},
	 = {
		 = true,
		 = true,
		 = true,
		 = true,
		 = true,
	},
}

local function maybe_get_weakcat(args, pos, binyan)
	if weakroots] then
		if binyan then
			return "Hebrew " .. pos .. "״" .. args .. " " .. binyan .. " verbs"
		else
			return "Hebrew " .. pos .. "״" .. args .. " verbs"
		end
	else
		return nil -- perhaps track error if args ~= ""
	end
end

pos_functions = function(args, data)
	local binyan = binyanim]
	if binyan then
		table.insert(data.inflections, { label="]" })
		table.insert(data.categories, "Hebrew " .. binyanim] .. " verbs")
	elseif args ~= "-" then
		table.insert(data.categories, "Hebrew verbs lacking binyan")
	end
	table.insert(data.categories, maybe_get_weakcat(args, "פ", binyan))
	table.insert(data.categories, maybe_get_weakcat(args, "ע", binyan))
	table.insert(data.categories, maybe_get_weakcat(args, "ל", binyan))
	table.insert(data.inflections, maybe_get_inflection(args, "infinitive", "inf", true))
	table.insert(data.inflections, maybe_get_inflection(args, "present", "pres", true))
	table.insert(data.inflections, maybe_get_inflection(args, "future", "fut", true))
	table.insert(data.inflections, maybe_get_inflection(args, "imperative", "imp", true))
	table.insert(data.inflections, maybe_get_inflection(args, "passive participle", "passp", true))
	table.insert(data.inflections, maybe_get_inflection(args, "passive counterpart", "pass", true))
	table.insert(data.inflections, maybe_get_inflection(args, "active counterpart", "act", true))
end

return export