Module:topos >> Module:topos/kind     <<   Module:topos/τεκμηρίωση (documentation) <<
Module:topos >> Module:topos/where
Module:topos >> Module:topos/functions
Το Module καλείται από το Πρότυπο:τόπος όπου υπάρχουν οδηγίες. Δείτε και την Κατηγορία:Τοπωνύμια.
Επιμέρους functions, χρήσιμες σε άλλα Modules υπάρχουν στο Module:topos/functions


-- Useful functions. Used by other modules, like [[Module:auto cat]]
-- 1) keywords from [[Module:topos/kind]]    
-- 2) keywords from [[Module:topos/where]]   

--[=[ 2020.11.09. Sarri.greek - Last update: 2020.11.10.
Needed for [[Module:auto cat]] the id of the first columns: kind and where (repeated as firstkeyword)
]=]--

local p = {}

--------------------------------------------------------------------------
--               keywords από το [[Module:topos/kind]]                  --
--------------------------------------------------------------------------
-- write one keyword - get another

--- ========== write word_cat - get the first keyword (kind) ============= -- they always exist
-- i need three keywords, the third keyword i choose is: word
function p.catword_to_firstkeyword(word_cat) -- word_cat is the name of the Category.
	local ret = {}
	local i = 1
	local word_to_char = {}
		for _, v in pairs(require("Module:topos/kind")) do
			local word_cat, word, kind = v.word_cat, v.word, v.kind
			word_to_char[word] = kind
			if word_cat then
				word_to_char[word_cat:gsub("[%*%?]", "")] = kind
			end
		end
	
	for c in mw.text.gsplit(word_cat, "%.") do
		ret[i] = word_to_char[c] or c
		i = i + 1
	end
	
	return table.concat(ret)
end


--------------------------------------------------------------------------
--               keywords από το [[Module:topos/where]]                  --
--------------------------------------------------------------------------
-- write one keyword - get another

--- ========== write word_cat - get the first keyword (where) ============= -- they always exist
function p.catword_to_firstwhere(word_cat) -- word_cat expression exists in the name of the Category.
	local ret = {}
	local i = 1
	local word_to_char = {}
		for _, v in pairs(require("Module:topos/where")) do
			local word_cat, word, where = v.word_cat, v.word, v.where
			word_to_char[word] = where
			if word_cat then
				word_to_char[word_cat:gsub("[%*%?]", "")] = where
			end
		end
	
	for c in mw.text.gsplit(word_cat, "%.") do
		ret[i] = word_to_char[c] or c
		i = i + 1
	end
	
	return table.concat(ret)
end



return p