మాడ్యూల్:Wikidata/doc
This is a documentation subpage for మాడ్యూల్:Wikidata. It may contain usage information, categories and other content that is not part of the original మాడ్యూల్ page. |
Module permitting basic data retrieval from Wikidata items, based on mw:Extension:Wikibase Client/Lua
Functions callable from Lua
మార్చుp.getClaims returns claims in a particular item that match a particular query
- item (required): its Qid
- property (required) property that the claims should have
- qualifier = qualifiers that the statement should have
- withrank = rank of the statement ; 'preferred', 'normal', 'deprecated' or 'valid' (ie. normal and preferred). By default = preferred.
- sourceproperty = this property should be used in the source
- withsource = the source that should be provided in the statement (if sourceproperty is not provided, the property used is ప్రస్తావింపు (P248))
- excludespecial = set to true if you do not want to get "novalue" and "somevalue".
- numval = if you want to set a maximum number of values to be returned
- sorttype = set to "chronological" to get the statements in chronological order using the ప్రారంభ సమయం (P580), ముగింపు తేదీ (P582) and ఈ సమయాన (P585) qualifiers. Set to "inverted" for chronological order. From a Lua module, you can also define your own sorting criteria.
- showsource = set to "true" if you want the source of the statement to be displayed.
p.formatStatements(args): returns a string containing the statements given in the table args. Same keys as getClaims, plus formatting arguments:
- lang (required) for the desired language
- displayformat = the format in which the args should be returned. For example, for a string-type property displayformat = "weblink" returns a formatted weblink.
- conjtype = the conjunction separating the statements. For example, conj = '<br />' will make a new line between each statement.
- showqualifiers = the qualifiers that should be shown along with the mainsnak value
p.getLabel get the label of an entity
- entity = entity ID with its Q or P
- lang
Functions callable from wikitext
మార్చు- p.formatStatementsE same as p.formatStatements, except that "lang" is not required. It is most conveniently used from {{Data}} that takes exactly the same arguments.
Examples
మార్చుCode | Render | Comment |
---|---|---|
{{#invoke:Wikidata|pageId}} | return wikidata q-code for pages connected to wikidata | |
{{#invoke:Wikidata|getLabel|entity=Q42|link=wikipedia}} | Script error: The function "getLabel" does not exist. | link to wikipedia |
{{#invoke:Wikidata|getLabel|entity=Q42|link=wikipedia|format=lc}} | Script error: The function "getLabel" does not exist. | link to wikipedia but shown with lower case |
{{#invoke:Wikidata|getLabel|entity=Q42|link=-}} | Script error: The function "getLabel" does not exist. | no links |
{{#invoke:Wikidata|getLabel|entity=Q42|link=wikipedia|lang=ja}} | Script error: The function "getLabel" does not exist. | |
{{#invoke:Wikidata|getLabel|entity=Q42|link=wikidata}} | Script error: The function "getLabel" does not exist. | link to wikidata |
{{#invoke:Wikidata|getLabel|entity=Q42|link=wikidata|lang=ja}} | Script error: The function "getLabel" does not exist. | |
{{#invoke:Wikidata|getDescription|entity=Q42|link=wikidata|lang=fr}} | Script error: The function "getDescription" does not exist. | |
{{#invoke:Wikidata|formatStatementsE|item=Q42|property=p31}} | Script error: The function "formatStatementsE" does not exist. | |
{{#invoke:Wikidata|formatStatementsE|item=Q42|property=p31|link=-}} | Script error: The function "formatStatementsE" does not exist. | |
{{#invoke:Wikidata|formatStatementsE|item=Q42|property=p31|lang=ja}} | Script error: The function "formatStatementsE" does not exist. | |
{{#invoke:Wikidata|formatStatementsE|item=Q42|property=p569}} | Script error: The function "formatStatementsE" does not exist. | |
{{#invoke:Wikidata|formatStatementsE|item=Q42|property=p569|lang=ja}} | Script error: The function "formatStatementsE" does not exist. | |
{{#invoke:Wikidata|formatStatementsE|item=Q12418|property=p186}} | Script error: The function "formatStatementsE" does not exist. | |
{{#invoke:Wikidata|formatStatementsE|item=Q12418|property=p186|link=-}} | Script error: The function "formatStatementsE" does not exist. | |
{{#invoke:Wikidata|formatStatementsE|item=Q12418|property=p186|displayformat=raw}} | Script error: The function "formatStatementsE" does not exist. | |
{{#invoke:Wikidata|formatStatementsE|item=Q12418|property=p186|lang=ja}} | Script error: The function "formatStatementsE" does not exist. | |
{{#invoke:Wikidata|formatStatementsE|item=Q12418|property=p186|rank=valid}} | Script error: The function "formatStatementsE" does not exist. | rank = "valid" accepts both "preferred" and "normal" values |
{{#invoke:Wikidata|formatStatementsE|item=Q12418|property=p186|showqualifiers=p518}} | Script error: The function "formatStatementsE" does not exist. | shows the value of the p518 qualifier (if any) in addition to the main value |
{{#invoke:Wikidata|formatStatementsE|item=Q83259|property=p669|showqualifiers=p670|delimiter= }} | Script error: The function "formatStatementsE" does not exist. | shows the value of the P670 qualifier (if any) in addition to the main value separated by a space |
{{#invoke:Wikidata|formatStatementsE|item=Q12418|property=p186|qualifier=p518}} | Script error: The function "formatStatementsE" does not exist. | should only display values that have a p518 qualifier |
{{#invoke:Wikidata|formatStatementsE|item=Q12418|property=p186|numval=1}} | Script error: The function "formatStatementsE" does not exist. | returns the number of values numval (priority to those with "rank= preferred", if there are not enough of them, also accepts "rank = normal") |
{{#invoke:Wikidata|formatStatementsE|item=Q12418|property=P276|sourceproperty=P854}} | Script error: The function "formatStatementsE" does not exist. | |
{{#invoke:Wikidata|formatStatementsE|item=Q11879536|property=P460|withsource=Q1645493}} | Script error: The function "formatStatementsE" does not exist. | |
{{#invoke:Wikidata|formatStatementsE|item=Q153|property=P231|showsource=true}} | Script error: The function "formatStatementsE" does not exist. | |
{{#invoke:Wikidata|formatStatementsE|item=Q205309|property=P793|sorttype=inverted}} | Script error: The function "formatStatementsE" does not exist. | |
{{#invoke:Wikidata|formatStatementsE|property=P625|item=Q90|displayformat=latitude}} | Script error: The function "formatStatementsE" does not exist. | Latitude of Paris |
{{#invoke:Wikidata|formatStatementsE|property=P19|item=Q1441042}} | Script error: The function "formatStatementsE" does not exist. | unknown value |
{{#invoke:Wikidata|formatStatementsE|property=P19|item=Q43650835}} | Script error: The function "formatStatementsE" does not exist. | no value |