Module:topos/functions: Διαφορά μεταξύ των αναθεωρήσεων

Από Βικιλεξικό
Μετάβαση στην πλοήγηση Πήδηση στην αναζήτηση
Περιεχόμενο που διαγράφηκε Περιεχόμενο που προστέθηκε
PROBLEMS
only functions needed for Module:auto cat, catword_to_first keyword at both data pages
 
Γραμμή 3: Γραμμή 3:
-- 2) keywords from [[Module:topos/where]]
-- 2) keywords from [[Module:topos/where]]


--[=[ 2020.11.09. Sarri.greek - Last update: 2020.11.09.
--[=[ 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)
PROBLEMS - check [[Module:autocat]] section TOPOS
* chek if expression at IF IT EXISTS is ok. It works only with 'and'
]=]--
]=]--


Γραμμή 15: Γραμμή 14:
-- write one keyword - get another
-- write one keyword - get another


--- ============ write first keyword - get name of category ============== -- word_cat ALWAYS EXISTS
-- I wish to get the keyword 'word_cat' if I write the first keyword, which is called 'kind'
-- I need word_cat, because it matches the name of Categories, the cat_title.
-- We need 3 keys for this function: kind, word_cat, and one more. I choose: word.

-- ???????????????? PROBLEM: It copies the cat_title of EVERY Category in wiktionary
function p.firstkeyword_to_catword(kind) -- kind is the name of the first keyword. You MUST use it
local ret = {}
local i = 1
local word_to_char = {}
for _, v in pairs(require("Module:topos/kind")) do
local kind, word, word_cat = v.kind, v.word, v.word_cat
word_to_char[word] = word_cat
if kind then
word_to_char[kind:gsub("[%*%?]", "")] = word_cat
end
end
for c in mw.text.gsplit(kind, "%.") do
ret[i] = word_to_char[c] or c
i = i + 1
end
return table.concat(ret)
end

-- ???????????????????????????????? FAIL. I do not know how to call the first keyword
-- perhaps I could create an extra keyword to REPEAT the first one, as a key
--- ========== write word_cat - get the first keyword (kind) ============= -- they always exist
--- ========== write word_cat - get the first keyword (kind) ============= -- they always exist
-- i need three keywords, the third keyword i choose is: word
-- i need three keywords, the third keyword i choose is: word
Γραμμή 66: Γραμμή 37:




--------------------------------------------------------------------------
--- ========== write word_cat - get the sorting key ============= -- key ALWAYS EXISTS
-- keywords από το [[Module:topos/where]] --
-- i need three keywords, the third keyword i choose is: word
--------------------------------------------------------------------------
function p.catword_to_catkey(word_cat) -- word_cat is the name of the Category.
-- write one keyword - get another
local ret = {}
local i = 1
local word_to_char = {}
for _, v in pairs(require("Module:topos/kind")) do
local word_cat, word, key = v.word_cat, v.word, v.key
word_to_char[word] = key
if word_cat then
word_to_char[word_cat:gsub("[%*%?]", "")] = key
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


--- ========== write word_cat - get parent ============= -- IF IT EXISTS
--- ========== 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.
-- i need three keywords, the third keyword i choose is: word
function p.catword_to_catparent(word_cat) -- word_cat is the name of the Category.
local ret = {}
local ret = {}
local i = 1
local i = 1
local word_to_char = {}
local word_to_char = {}
for _, v in pairs(require("Module:topos/kind")) do
for _, v in pairs(require("Module:topos/where")) do
local word_cat, word, parent = v.word_cat, v.word, v.parent
local word_cat, word, where = v.word_cat, v.word, v.where
word_to_char[word] = parent
word_to_char[word] = where
if word_cat then
if word_cat then
word_to_char[word_cat:gsub("[%*%?]", "")] = parent
word_to_char[word_cat:gsub("[%*%?]", "")] = where
end
end
end
end
Γραμμή 107: Γραμμή 60:
end
end
if parent == '' or parent == nil then return '' else -- check [[:Κατηγορία:Ωκεανοί]]
return table.concat(ret)
return table.concat(ret)
end
end
end


--- ========== write word_cat - get parent2 ============= -- IF IT EXISTS
-- i need three keywords, the third keyword i choose is: word
function p.catword_to_catparent2(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, parent2 = v.word_cat, v.word, v.parent2
word_to_char[word] = parent2
if word_cat then
word_to_char[word_cat:gsub("[%*%?]", "")] = parent2
end
end
for c in mw.text.gsplit(word_cat, "%.") do
ret[i] = word_to_char[c] or c
i = i + 1
end
if parent2 == '' or parent2 == nil then return '' else
return table.concat(ret)
end
end


--- ========== write word_cat - get parent3 ============= -- IF IT EXISTS
-- i need three keywords, the third keyword i choose is: word
function p.catword_to_catparent3(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, parent3 = v.word_cat, v.word, v.parent3
word_to_char[word] = parent3
if word_cat then
word_to_char[word_cat:gsub("[%*%?]", "")] = parent3
end
end
for c in mw.text.gsplit(word_cat, "%.") do
ret[i] = word_to_char[c] or c
i = i + 1
end
if parent3 == '' or parent3 == nil then return '' else
return table.concat(ret)
end
end


--- ========== write word_cat - get parent4 ============= -- IF IT EXISTS
-- i need three keywords, the third keyword i choose is: word
function p.catword_to_catparent4(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, parent4 = v.word_cat, v.word, v.parent4
word_to_char[word] = parent4
if word_cat then
word_to_char[word_cat:gsub("[%*%?]", "")] = parent4
end
end
for c in mw.text.gsplit(word_cat, "%.") do
ret[i] = word_to_char[c] or c
i = i + 1
end
if parent4 == '' or parent4 == nil then return '' else -- or works for [[:Κατηγορία:Αεροδρόμια]]
return table.concat(ret)
end
end


--- ========== write word_cat - get extra1 ============= -- IF IT EXISTS
-- i need three keywords, the third keyword i choose is: word
function p.catword_to_catextra1(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, extra1 = v.word_cat, v.word, v.extra1
word_to_char[word] = extra1
if word_cat then
word_to_char[word_cat:gsub("[%*%?]", "")] = extra1
end
end
for c in mw.text.gsplit(word_cat, "%.") do
ret[i] = word_to_char[c] or c
i = i + 1
end
if extra1 == '' or extra1 == nil then return '' else
return table.concat(ret)
end
end

--- ========== write word_cat - get extra2 ============= -- IF IT EXISTS
-- i need three keywords, the third keyword i choose is: word
function p.catword_to_catextra2(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, extra2 = v.word_cat, v.word, v.extra2
word_to_char[word] = extra2
if word_cat then
word_to_char[word_cat:gsub("[%*%?]", "")] = extra2
end
end
for c in mw.text.gsplit(word_cat, "%.") do
ret[i] = word_to_char[c] or c
i = i + 1
end
if extra2 == '' or extra2 == nil then return '' else
return table.concat(ret)
end
end


--- ========== write word_cat - get extra3 ============= -- IF IT EXISTS
-- i need three keywords, the third keyword i choose is: word
function p.catword_to_catextra3(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, extra3 = v.word_cat, v.word, v.extra3
word_to_char[word] = extra3
if word_cat then
word_to_char[word_cat:gsub("[%*%?]", "")] = extra3
end
end
for c in mw.text.gsplit(word_cat, "%.") do
ret[i] = word_to_char[c] or c
i = i + 1
end
if extra3 == '' or extra3 == nil then return '' else
return table.concat(ret)
end
end


return p
return p

Τελευταία αναθεώρηση της 12:03, 10 Νοεμβρίου 2020

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

CheckCheck

-- 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