Module:ha-headword

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

Backend for {{ha-noun}}.


local u = require("Module:string/char")

local export = {}

local lang = require("Module:languages").getByCode("ha")
local GRAVE = u(0x0300)
local ACUTE = u(0x0301)

local vowels = {
	 = true,  = true,  = true,  = true,  = true,
	 = true,  = true,  = true,  = true,  = true,
	 = true,  = true,  = true,  = true,  = true,
	 = true,  = true,  = true,  = true,  = true,
	 = true,  = true,  = true,  = true,  = true,  =true,  = true
}

local long_vowels = { = 'a',  = 'e',  = 'i',  = 'o',  = 'u',  = "è",  = "ò"}

local allowed_genders = { = true,  = true,  = true}

function replace_last_vowel(term)
	local vowel_index = nil
	local vowel = nil
	for i = 1, mw.ustring.len(term) do
		local char = mw.ustring.sub(term,i,i)
		if vowels then
			vowel_index = i
			vowel = char
		end
	end
	if vowel_index then
		if long_vowels then
			return mw.ustring.sub(term, 1, vowel_index-1) .. long_vowels .. mw.ustring.sub(term, vowel_index+1, mw.ustring.len(term))
		end
	end
	return term
end

function export.generate_possessed_form(term, gender)
	-- replace last vowel with short vowel
	term = replace_last_vowel(term)
	
	local stripped_term = mw.ustring.gsub(term, ACUTE, '')
	stripped_term = mw.ustring.gsub(stripped_term, GRAVE, '')
	
	local length = mw.ustring.len(stripped_term)
	
	local final_char = mw.ustring.sub(stripped_term,length,length)
	
	-- ends with consonant
	if not vowels then return nil end
	
	-- contains space
	if mw.ustring.match(term, '%s') then return nil end
	
	-- feminine and ends with a
	if gender == 'f' and (final_char == 'a' or final_char == 'à') then return mw.ustring.toNFC(term .. 'r̃') end
	
	-- ends in ai or au
	local suffix = mw.ustring.sub(stripped_term,length-1,length-1) .. final_char
	if suffix == 'ai' or suffix == 'au' or suffix == 'àu' or suffix == 'ài' then return mw.ustring.toNFC(mw.ustring.sub(term,1,length-1) .. 'n') end
	
	-- otherwise
	return mw.ustring.toNFC(term .. 'n')
	
end

function export.noun(frame)
	local params = {
		 = { required = true }, --gender
		 = {}, --alternate gender
		
		 = { required = true }, --head

		 = {}, --feminine form
		 = {}, -- second feminine form
		 = {}, -- third feminine form
		
		 = {}, --plural
		 = {}, --alternate plural
		 = {}, --alternate plural
		
		 = {} --possessed form
	}
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	
	local data = {lang = lang,
		pos_category = "nouns",
		categories = {},
		heads = {},
		genders = {},
		inflections = {}}
	
	if args then
		if allowed_genders] then
			table.insert(data.genders, args)
		else
			table.insert(data.categories, "Hausa entries with invalid gender")
		end
		if args then
			if allowed_genders] then
				table.insert(data.genders, args)
			else
				table.insert(data.categories, "Hausa entries with invalid gender")
			end
		end
	else
		table.insert(data.genders, '?')
	end
	
	if args then
		table.insert(data.heads, args)
	else
		table.insert(data.categories, "Hausa entries missing head parameter")
	end
	
	if args then
		local f_table = {label = "feminine", {term = args}}
		if args then
			table.insert(f_table, {term = args})
		end
		if args then
			table.insert(f_table, {term = args})
		end
		
		table.insert(data.inflections, f_table)
	end
	
	if args then
		local plural_table = {label = "plural", args}
		if args then
			table.insert(plural_table, args)
			if args then
				table.insert(plural_table, args)
			end
		end
		table.insert(data.inflections, plural_table)
	end
	
	if args then
		if args ~= "-" then
			table.insert(data.inflections, {label = "possessed form", args})
		end
	else
		if args then
			local generated_possessed_form = export.generate_possessed_form(args, args)
			if generated_possessed_form then
				table.insert(data.inflections, {label = "possessed form", generated_possessed_form})
			end
		end
	end
	
	return require("Module:headword").full_headword(data)
	
end
	
return export