For faster navigation, this Iframe is preloading the Wikiwand page for Module:Propriétés.

Module:Propriétés

 Documentation[créer] [purger]

Voir les statistiques d'utilisation du module sur l'outil wstat.

local p = {
	instance_de= "P31",
    sous_classe_de = "P279",
    prenom = "P735",
    nomdefamille = "P734", 
    isbn10 = "P957",
    publie_dans = "P1433",
    langue = "P407" 
}
-- this module gives solutions to get the Pnumber of a property by its name


-- could be automatized, but for now just defining a muanual mapping


p.p_from_name = {
	["country"] = 17 ;
	["gender"] = 21 ;

	["instance of"] = 31 ;
	
	["field"] = 101 ; 
	["occupation"] = 106 ;
	
	["genre"] = 136 ;
	
	["named after"] = 138 ;
	
	
	["preceded by"] = 155;
	["succeeded by"] = 156;
	["collection"] = 195;	
	["subclass of"] = 279 ;

	["category's topic"] = 301;

	["list of"] = 360 ; 
	["part of"] = 361 ;

	["commons category"] = 373;
	
	["terminus"] = 559;
	["direction"] = 560;
	
	["start date"] = 580 ;
	["begin date"] = 580 ;
	
	["end date"] = 582 ;
	
	["date"] = 585 ;
	
	["of"] = 642 ;
	
	["participant"] = 710 ;
	
	["edition"] = 747 ;
	["edition of"] = 629 ;
	
	['key event'] = 793 ;
	['significant event'] = 793 ;
	
	["topic's category"] = 910;
	["subject"] = 921; -- work subject
	["inspired by"] = 941 ;	
	
	["fictional analog of"] = 1074 ;

	["statement disputed by"] = 1310 ;
	["disputed by"] = 1310 ;
	
	["of"] = 642 ;
	
	["history"] = 2184 ;
	
	["property for this type"] = 1963 ;
    ["metasubclass of"] = 2445 ;
    
	["number"] = 1114 ;
	
	["union of"] = 2737;
	["disjoint union of"] = 2738;
	
	["has part of the type"] = 2670 ;
}



local function string_to_propnumber(label)
	local res = p.p_from_name[label] ;
	if res ~= nil then
		return tostring( res) ;
	else
		res = mw.wikibase.resolvePropertyId(label)
		if res then
			return string.sub(res, 2)
		else
			return nil
		end
    end
end

p.numberFromPropertylabel = function(frame)  
	local label = frame.args[1] ;
	mw.log(label)
	return string_to_propnumber(label)
end;

-- returns a pid of the form "Pnnn..." where n is a character in "123456789"
--from either 
--* a number representing a property wikidata number
--* a string number representing a property wikidata number
--* a pid of the form "Pnnn"
--* a "property name" corresponding to a property, where the names are listed in the array p.p_from_name
-- or "nil" if the id does not match to any of the cases above
p.normalize = function(input_pid)
	local input_pid = tostring(input_pid)
	if mw.ustring.match(input_pid, "P%d+") then
		return input_pid
	elseif mw.ustring.match(input_pid, "%d+") then
		return "P" .. input_pid
	else
		return "P" .. tostring(string_to_propnumber(input_pid))
	end
end

-- function that takes a string with a set of pids and returns an array of properties
p.expandPropList = function(plist)
	local props = mw.text.split(plist,",")
	for ind, val in ipairs(props) do
		props[ind] = p.normalize(val)
	end
	return props
end

function p.datatype(property)
	if type(property) ~= "table" then
		property = mw.wikibase.getEntityObject(p.normalize(property))
	end
	return property.datatype
end

---------------------------------------------------------------
-- wikitemplate interface
---------------------------------------------------------------

p.Pid = function(frame)  
	local label = frame.args[1] ;
	return p.normalize(label)
end;

p.Pdatatype = function(frame)
	return p.datatype(frame.args[1])
end;


p.of = p.normalize("of")
p.union_of = p.normalize("union of")
p.disjoint_union_of = p.normalize("disjoint union of")

return p
{{bottomLinkPreText}} {{bottomLinkText}}
Module:Propriétés
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.