For faster navigation, this Iframe is preloading the Wikiwand page for Module:Wikidata/Chemin/Resultat.

Module:Wikidata/Chemin/Resultat

 Documentation[voir] [modifier] [historique] [purger]

Utilisation

Fonctions exportables hhg:

  • fonction(frame) – dyvu euy d erd ehbc hlvescription (courte description de fonction(frame) et autres informations pertinentes).
  • fonction2() – description2 (courte description de fonction2() et autres informations pertinentes).

Autres fonctions :

  • fonction() – description2 (courte description de fonction() et autres informations pertinentes).

Modules externes et autres éléments dont ce module a besoin pour fonctionner :

  • mw.title – description (courte description expliquant la dépendance de ce module externe).

Exemples

Pour des exemples, voir la page de test permettant de tester diverses modifications apportées.



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

local p = {}

p.ResultNode = {}

function p.ResultNode:new (o)
  local o = o or {}
  o.is_RNode = true
  setmetatable(o, self)
  self.__index = self
  return o
end

function p.ResultNode:has_an_entity()
  local value_snak = self:snak()
  return value_snak.snaktype == "value" 
         and value_snak.datavalue.type == "wikibase-entityid"
end


function p.ResultNode:has_a_property()
  local value_snak = self:snak()
  return value_snak.snaktype == "value"  and value_snak.datatype == "wikibase-property"
         and value_snak.datavalue.type == "wikibase-entityid"
end

function p.ResultNode:has_an_item()
  local value_snak = self:snak()
  return value_snak.snaktype == "value" and value_snak.datatype == "wikibase-item"
         and value_snak.datavalue.type == "wikibase-entityid"
end

-- precondition : ResultNode:has_an_item()
function p.ResultNode:item_value()
  local value_snak = self:snak()
  if(not(value_snak["datavalue"] )) then return nil end
  return "Q" .. tostring(value_snak.datavalue.value['numeric-id'])
end

-- precondition : ResultNode:has_an_entity()
function p.ResultNode:entity_value()
  local value_snak = self:snak()
  if(not(value_snak["datavalue"] )) then return nil end
  return value_snak.datavalue.value['id']
end

-- subclassing
p.StatementRNode = p.ResultNode:new()
p.QualifierRNode = p.ResultNode:new()
p.EpsilonRNode = p.ResultNode:new()

function p.StatementRNode:create(statement, previous_node)
	setmetatable(statement, self)
	statement.parent = previous_node
	self.__index = self
	return statement
end

function p.QualifierRNode:create(snak, statement)
	setmetatable(snak, self)
	snak.parent = statement
	self.__index = self
	return snak
end

function p.EpsilonRNode:create(item, parent, o)
	local o = o or {}
	o.item = item
	o.parent = parent
	setmetatable(o, self)
	self.__index = self
	return o
end

function p.EpsilonRNode:has_an_item()
  return true
end

function p.EpsilonRNode:item_value()
  return self.item
end

function p.StatementRNode:snak()
	return self.mainsnak
end

function p.QualifierRNode:snak()
	return self
end

return p
{{bottomLinkPreText}} {{bottomLinkText}}
Module:Wikidata/Chemin/Resultat
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.