Jump to content

Module:he-roots-missing

From Wiktionary, the free dictionary


local p = {}

local CEDHL = require("Module:R:CEDHL")
local HWSS = require("Module:R:he:HWSSRoot")
local utilities = require("Module:he-utilities")
local missing_roots = require("Module:he-roots-missing/data")

local function min(a, b)
	if a <= b then
		return a
	else
		return b
	end
end

function p.row(root)
	local root_no_dashes = root:gsub("־", "")
	local root_shin = root:gsub("שׁ" ,"ש"):gsub("שׂ", "ש")
	local root_shin_no_dashes = root_no_dashes:gsub("שׁ" ,"ש"):gsub("שׂ", "ש")
	local root_romanized = utilities.romanized_root({args={root_no_dashes}})
	local r =  "<tr>"

	-- Root
	r = r
		.. "<td>[["
		.. root_shin
		.. "|"
		.. root
		.. "]] ("
		.. root_romanized
		.. ")</td>"

	-- Category
	local cat = "Hebrew terms belonging to the root " .. root
	local size = mw.getCurrentFrame():preprocess("{{PAGESINCAT:" .. cat .. "}}")
	r = r
		.. "<td>[[:Category:"
		.. cat
		.. "|"
		.. size
		.. " entries]]</td>"

	-- HTD
	local HTD_root = root:gsub("ה$", "י")
	local HTD_root_no_dashes = root_no_dashes:gsub("ה$", "י")
	local HTD_root_romanized = root_romanized:gsub("h$", "y")
	r = r
		.. "<td>"
		.. "[https://terms.hebrew-academy.org.il/Home/Advanced?SearchBy=2&SearchType=3&SearchString="
			.. HTD_root_no_dashes
			.. " "
			.. HTD_root
		.. "]</td>"

	local altform = ""
	if HTD_root ~= root then
		altform = mw.uri.encode("\n===Alternative forms===\n* {{alter|he|" .. HTD_root .. "|tr=" .. HTD_root_romanized .. "}}\n")
	end
	-- Pealim
	r = r .. "<td>"
	local length = mw.ustring.len(root_shin_no_dashes)
	if length < 3 or length > 4 then
		r = r .. "—"
	else
		r = r .. "[{{R:he:PealimRoot/url|" .. root_shin_no_dashes .. "}} " .. root .. "]"
	end
	r = r .. "</td>"

	-- CEDHL
	local CEDHL_page = CEDHL.page_number({args={root_no_dashes}})
	r = r
		.. "<td>"
		.. "[https://www.sefaria.org/search?q="
			.. root_no_dashes
			.. "&tpathFilters=Reference%2FDictionary%2FKlein%20Dictionary "
			.. root_no_dashes
		.. "] (?)<br/>"
		.. "[https://archive.org/details/AComprehensiveEtymologicalDictionaryOfTheHebrewLanguageErnestKlein1987OCR/page/n"
			.. (15+CEDHL_page)
			.. " page "
			.. CEDHL_page
			.. "] (?)"
		.. "</td>"

	-- HWSS
	local HWSS_root = HWSS.hebrew_to_normalized_latin(root_no_dashes)
	local HWSS_page = HWSS.page_number({args={root_no_dashes}})
	r = r
		.. "<td>"
		.. HWSS_root
		.. " (?)<br/>"
		.. "[https://archive.org/details/murtonen-hebrew-in-its-west-semitic-setting-part-i-1989/page/"
			.. HWSS_page
			.. " page "
			.. HWSS_page
		.. "] (?)"
		.. "</td>"

	r = r
		.. "<td>[https://en.wiktionary.org/?action=edit&preload=Template:he-root-preload&title="
		.. root_shin
		.. "&preloadparams%5b%5d=" -- $1
		.. root
		.. "&preloadparams%5b%5d=" -- $2
		.. root_romanized
		.. "&preloadparams%5b%5d=" -- $3
		.. HTD_root
		.. "&preloadparams%5b%5d=" -- $4
		.. root_no_dashes
		.. "&preloadparams%5b%5d=" -- $5
		.. CEDHL_page
		.. "&preloadparams%5b%5d={{urlencode:" -- $6
		.. HWSS_root
		.. "}}&preloadparams%5b%5d=" -- $7
		.. HWSS_page
		.. "&preloadparams%5b%5d=" -- $8
		.. altform
		.. " preload]"
		.. "</td>"

	r = r .. "</tr>"
	return r
end

function p.table(frame)
	local pagination = frame.args[1]
	local output = ""
	local i = 250*(pagination-1) + 1
	while i <= min(250*pagination, #missing_roots) do
		output = output .. p.row(missing_roots[i])
		i = i + 1
	end
	return frame:preprocess(output)
end

return p