Module:he-common

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

This module holds some common used functions for Hebrew, that are needed by other modules.


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

-- A nil-safe, Hebrew-specific diacritic remover.
function export.remove_nikud(formwv)
	return formwv and (lang:makeEntryName(formwv))
end

local vowels = "ְֱֲֳִֵֶַָֹֻ"
local dagesh = "ּֿ"
local shin_dots = "ׁׂ"
local vowels_regex = ""
local dagesh_regex = ""
local shin_dots_regex = ""
local nikud_regex = ""

local function fix_nikud_subber(x)
    local s = ""
    local d = ""
    local v = ""
    local subber = function(y)
        if mw.ustring.match(y, shin_dots_regex) then
            s = s .. y
        elseif mw.ustring.match(y, dagesh_regex) then
            d = d .. y
        else
            v = v .. y
        end
    end
    mw.ustring.gsub(x, ".", subber)
    return s .. d .. v
end

function export.fix_nikud(x)
    return mw.ustring.gsub(x, nikud_regex .. "+", fix_nikud_subber)
end

function export.end_with_makaf(string)
	if string == "" or string == nil then return string end
	if mw.ustring.sub(string, -1) ~= "־" then
		string = string .. "־"
	end
	return string
end

-- This should only be used by modules that auto-generate words, otherwise use gen_link
function export.process_wv_triad(form, formwv, formdwv)
	if form then
		return form, formwv, formdwv
	elseif formwv then
		return export.remove_nikud(formwv), formwv, formdwv
	else
		return export.remove_nikud(formdwv), formdwv, nil
	end
end

function export.gen_link(form, formwv, formdwv)
	form, formwv, formdwv = export.process_wv_triad(form, formwv, formdwv)
	if not form then
		error("Can't make a link out of nothing.")
	end
	if formdwv then
		return "]"
	else
		return "]"
	end
end

-- Like gen_link for construct forms appends a makaf if one doesn't already exist
function export.gen_link_ending_with_makaf(form, formwv, formdwv)
	form, formwv, formdwv = export.process_wv_triad(form, formwv, formdwv)
	if not form then
		error("Can't make a link out of nothing.")
	end
	if formdwv then
		return "]"
	else
		return "]"
	end
end

return export