Difference between revisions of "Wikidata"

From BITPlan Wiki
Jump to navigation Jump to search
 
(19 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
= The Genesis of WikiData =
 
= The Genesis of WikiData =
# In the beginning there was the [https://tools.wmflabs.org/sqid/#/view?id=Q1 Universe] [https://www.wikidata.org/wiki/Q1 Q1].
+
{{Link|target=The Genesis of WikiData}}
# [https://tools.wmflabs.org/sqid/#/view?id=Q2 Earth] [https://www.wikidata.org/wiki/Q2 Q2]was at the center of it.
+
 
# After a while [https://tools.wmflabs.org/sqid/#/view?id=Q3 Life] [https://www.wikidata.org/wiki/Q3 Q3] showed up on it.
 
# [https://tools.wmflabs.org/sqid/#/view?id=Q4 Death] [https://www.wikidata.org/wiki/Q4 Q4] set time limits to it.
 
# [https://tools.wmflabs.org/sqid/#/view?id=Q5 Man] [https://www.wikidata.org/wiki/Q5 Q5] recently entered the scene in this chain of life and death.
 
# [https://tools.wmflabs.org/sqid/#/view?id=Q6 void] [https://www.wikidata.org/wiki/Q6 Q6] is void and so is 
 
[https://www.wikidata.org/wiki/Q6 Q6]
 
# [https://tools.wmflabs.org/sqid/#/view?id=Q8 Happiness] [https://www.wikidata.org/wiki/Q8 Q8] <youtube>v=eMD_SWtPzlk</youtube>
 
 
= Links =
 
= Links =
 +
* {{Link|target=Get your own copy of WikiData}}
 +
* [https://www.mediawiki.org/wiki/Wikibase/DataModel WikiBase DataModel]
 +
*  https://www.wikidata.org/wiki/Special:GoToLinkedPage/enwiki/Q5
 +
 
= Structure =
 
= Structure =
 +
see also https://addshore.com/2018/12/wikidata-architecture-overview-diagrams/
 
https://www.mediawiki.org/wiki/Wikibase/DataModel/Primer
 
https://www.mediawiki.org/wiki/Wikibase/DataModel/Primer
 
<uml>
 
<uml>
Line 45: Line 44:
 
[[File:Wikibase_JavaScript_Data_Model_1.0.svg]]
 
[[File:Wikibase_JavaScript_Data_Model_1.0.svg]]
 
https://upload.wikimedia.org/wikipedia/commons/c/c2/Wikibase_JavaScript_Data_Model_1.0.svg
 
https://upload.wikimedia.org/wikipedia/commons/c/c2/Wikibase_JavaScript_Data_Model_1.0.svg
 +
 
= Example =
 
= Example =
 
Æthelstan King of the English - 927-939
 
Æthelstan King of the English - 927-939
Line 101: Line 101:
 
</source>
 
</source>
 
[https://query.wikidata.org/#%23%20WikiData%20SPARQL%20Query%0A%23%0A%23%20Wolfgang%20Fahl%202018-01-06%0A%23%0A%23%20get%20childen%20of%20queen%20victoria%0ASELECT%20%3Fchild%20%3FchildLabel%20%3FgenderLabel%20%3Fdob%0AWHERE%20%7B%0A%23%20%20%0A%23%20child%0A%23%20https%3A%2F%2Fwww.wikidata.org%2Fwiki%2FProperty%3AP40%0A%23%20Queen%20Victoriy%0A%23%20https%3A%2F%2Fwww.wikidata.org%2Fwiki%2FQ9439%0A%20%20wd%3AQ9439%20wdt%3AP40%2B%20%3Fchild.%0A%23%20gender%0A%23%20https%3A%2F%2Fwww.wikidata.org%2Fwiki%2FProperty%3AP21%0A%20%20%3Fchild%20wdt%3AP21%20%3Fgender.%0A%23%20date%20of%20birth%0A%23%20https%3A%2F%2Fwww.wikidata.org%2Fwiki%2FProperty%3AP569%20%20%20%20%20%20%20%20%20%0A%20%20%3Fchild%20wdt%3AP569%20%3Fdob%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22en%22.%20%7D%0A%7D%0AORDER%20BY%20%3Fdob%0A try it!]
 
[https://query.wikidata.org/#%23%20WikiData%20SPARQL%20Query%0A%23%0A%23%20Wolfgang%20Fahl%202018-01-06%0A%23%0A%23%20get%20childen%20of%20queen%20victoria%0ASELECT%20%3Fchild%20%3FchildLabel%20%3FgenderLabel%20%3Fdob%0AWHERE%20%7B%0A%23%20%20%0A%23%20child%0A%23%20https%3A%2F%2Fwww.wikidata.org%2Fwiki%2FProperty%3AP40%0A%23%20Queen%20Victoriy%0A%23%20https%3A%2F%2Fwww.wikidata.org%2Fwiki%2FQ9439%0A%20%20wd%3AQ9439%20wdt%3AP40%2B%20%3Fchild.%0A%23%20gender%0A%23%20https%3A%2F%2Fwww.wikidata.org%2Fwiki%2FProperty%3AP21%0A%20%20%3Fchild%20wdt%3AP21%20%3Fgender.%0A%23%20date%20of%20birth%0A%23%20https%3A%2F%2Fwww.wikidata.org%2Fwiki%2FProperty%3AP569%20%20%20%20%20%20%20%20%20%0A%20%20%3Fchild%20wdt%3AP569%20%3Fdob%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22en%22.%20%7D%0A%7D%0AORDER%20BY%20%3Fdob%0A try it!]
 +
= How Triples are stored in WikiData =
 +
== Regular triple ==
 +
<graphviz>
 +
digraph Triple {
 +
  rankdir="LR"
 +
  subject -> predicate -> object
 +
}
 +
</graphviz>
 +
== WikiData Example Queen Victoria's father ==
 +
<graphviz>
 +
digraph TripleExample {
 +
  rankdir="LR"
 +
  "QueenVictoria" -> "father" -> "Prince Edward Augustus"
 +
}
 +
</graphviz>
 +
 +
=== WikiData Example Queen Victoria's father (technically) ===
 +
<graphviz>
 +
digraph TripleWikiData {
 +
  Q9439  [ URL="http://www.wikidata.org/entity/Q9439" ]
 +
  Q9439 -> "Queen Victoria" [ label="label" ]
 +
  P22    [ URL="http://www.wikidata.org/property/P22" ]
 +
  P22 -> "father" [ label="label" ]
 +
  Q157009 [ URL="http://www.wikidata.org/entity/Q157009" ]
 +
  Q157009 -> "Prince Edward Augustus" [ label="label" ]
 +
  Q9439 -> P22 -> Q157009
 +
}
 +
</graphviz>
 +
 +
=== WikiData Example Queen Victoria's father (multiple languages) ===
 +
<graphviz>
 +
digraph TripleWikiDataMultiLanguage {
 +
  Q9439  [ URL="http://www.wikidata.org/entity/Q9439" ]
 +
  Q9439 -> "Queen Victoria" [ label="label_en" ]
 +
  Q9439 -> "Königin Victoria" [ label="label_de" ]
 +
  P22    [ URL="http://www.wikidata.org/property/P22" ]
 +
  P22 -> "father" [ label="label_en" ]
 +
  P22 -> "vater" [ label="label_de" ]
 +
  Q157009 [ URL="http://www.wikidata.org/entity/Q157009" ]
 +
  Q157009 -> "Prince Edward Augustus" [ label="label_en" ]
 +
  Q157009 -> "Prinz Edward August" [ label="label_de" ]
 +
  Q9439 -> P22 -> Q157009
 +
}
 +
</graphviz>
 +
=== Queen Victoria's father SPARQL Query ===
 +
<source lang='sparql'>
 +
# WikiData SPARQL Query
 +
#
 +
# Wolfgang Fahl 2018-01-06
 +
# see also https://stackoverflow.com/a/48341522/1497139
 +
#
 +
# get father of queen victoria
 +
SELECT ?queenVictoria ?queenVictoriaLabel ?fatherProperty ?fatherPropertyLabel ?father ?fatherLabel
 +
WHERE {
 +
 +
# father
 +
# https://www.wikidata.org/wiki/Property:P42
 +
# Queen Victoria
 +
# https://www.wikidata.org/wiki/Q9439
 +
VALUES (?queenVictoria) {(wd:Q9439)}
 +
VALUES (?property) {(wdt:P22)}
 +
?queenVictoria ?property ?father.
 +
?fatherProperty wikibase:directClaim ?property
 +
SERVICE wikibase:label { bd:serviceParam wikibase:language "fr". }
 +
}
 +
</source>
 +
[https://query.wikidata.org/#%23%20WikiData%20SPARQL%20Query%0A%23%0A%23%20Wolfgang%20Fahl%202018-01-06%0A%23%0A%23%20get%20father%20of%20queen%20victoria%0ASELECT%20%3FqueenVictoria%20%3FqueenVictoriaLabel%20%3FfatherProperty%20%3FfatherPropertyLabel%20%3Ffather%20%3FfatherLabel%0AWHERE%20%7B%0A%23%20%20%0A%23%20father%0A%23%20https%3A%2F%2Fwww.wikidata.org%2Fwiki%2FProperty%3AP42%0A%23%20Queen%20Victoria%0A%23%20https%3A%2F%2Fwww.wikidata.org%2Fwiki%2FQ9439%0AVALUES%20%28%3FqueenVictoria%29%20%7B%28wd%3AQ9439%29%7D%0AVALUES%20%28%3Fproperty%29%20%7B%28wdt%3AP22%29%7D%0A%3FqueenVictoria%20%3Fproperty%20%3Ffather.%0A%3FfatherProperty%20wikibase%3AdirectClaim%20%3Fproperty%0ASERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22fr%22.%20%7D%0A%7D%0A%0A try it!]
  
 
= Import =
 
= Import =
 +
* {{Link|target=Get_your_own_copy_of_WikiData}}
 
* https://www.wikidata.org/wiki/Wikidata:Data_Import_Guide
 
* https://www.wikidata.org/wiki/Wikidata:Data_Import_Guide
 
* https://www.wikidata.org/wiki/Q2140665
 
* https://www.wikidata.org/wiki/Q2140665
 
* https://github.com/maxlath/wikidata-cli
 
* https://github.com/maxlath/wikidata-cli
 
* https://www.wikidata.org/wiki/Wikidata:Tools/External_tools
 
* https://www.wikidata.org/wiki/Wikidata:Tools/External_tools
 +
== Virtuoso Import ==
 +
* http://wikidata.demo.openlinksw.com/sparql -- SPARQL endpoint
 +
* http://wikidata.demo.openlinksw.com/fct -- Faceted Browsing Interface
 +
* https://wikidata.demo.openlinksw.com/describe/?url=http%3A%2F%2Fwww.wikidata.org%2Fentity%2FQ60&gp=16&go=&lp=940&invfp=IFP_OFF&sas=SAME_AS_OFF&distinct=1
 +
 +
= Ontology =
 +
* https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions/Wikibase/+/master/docs/ontology.owl
 +
* https://www.mediawiki.org/wiki/Wikibase/DataModel
 +
 
= Tools =
 
= Tools =
 
* https://github.com/maxlath/wikidata-cli/blob/master/docs/write_operations.md#wd-create-item
 
* https://github.com/maxlath/wikidata-cli/blob/master/docs/write_operations.md#wd-create-item
 +
* https://quickstatements.toolforge.org
  
 
= What Links Here =
 
= What Links Here =
 
{{WhatLinksHere}}
 
{{WhatLinksHere}}
 
[[Category:SiGNaL]]
 
[[Category:SiGNaL]]
 +
[[Category:frontend]]
  
 
* https://www.mediawiki.org/wiki/API:Presenting_Wikidata_knowledge
 
* https://www.mediawiki.org/wiki/API:Presenting_Wikidata_knowledge
 +
[[Category:Wikidata]]

Latest revision as of 07:22, 18 April 2023

The Genesis of WikiData

The Genesis of WikiData

Links

Structure

see also https://addshore.com/2018/12/wikidata-architecture-overview-diagrams/ https://www.mediawiki.org/wiki/Wikibase/DataModel/Primer

Wikibase JavaScript Data Model 1.0.svg https://upload.wikimedia.org/wikipedia/commons/c/c2/Wikibase_JavaScript_Data_Model_1.0.svg

Example

Æthelstan King of the English - 927-939

Position Held


Queen Victoria

Entity:Queen Victoria

Statements
PropertyId/name value
P18/image 250px-Queen_Victoria_by_Bassano.jpg
P569/date of birth 24 May 1819
P39/position held Q9134365/Monarch of the United Kingdom qualifiers -> start:20 June 1837, end:22 January 1901, replaced by:https://www.wikidata.org/wiki/Q20875
P570/date of death 22 January 1901
P20/place of death Osborne House
P21/sex or gender] Q6581072/female

Descendants of Queen Victoria

# WikiData SPARQL Query
#
# Wolfgang Fahl 2018-01-06
#
# get childen of queen victoria
SELECT ?child ?childLabel ?genderLabel ?dob
WHERE {
#  
# child
# https://www.wikidata.org/wiki/Property:P40
# Queen Victoria
# https://www.wikidata.org/wiki/Q9439
  wd:Q9439 wdt:P40+ ?child.
# gender
# https://www.wikidata.org/wiki/Property:P21
  ?child wdt:P21 ?gender.
# date of birth
# https://www.wikidata.org/wiki/Property:P569         
  ?child wdt:P569 ?dob
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
ORDER BY ?dob

try it!

How Triples are stored in WikiData

Regular triple

WikiData Example Queen Victoria's father

WikiData Example Queen Victoria's father (technically)

WikiData Example Queen Victoria's father (multiple languages)

Queen Victoria's father SPARQL Query

# WikiData SPARQL Query
#
# Wolfgang Fahl 2018-01-06
# see also https://stackoverflow.com/a/48341522/1497139
#
# get father of queen victoria
SELECT ?queenVictoria ?queenVictoriaLabel ?fatherProperty ?fatherPropertyLabel ?father ?fatherLabel
WHERE {
#  
# father
# https://www.wikidata.org/wiki/Property:P42
# Queen Victoria
# https://www.wikidata.org/wiki/Q9439
VALUES (?queenVictoria) {(wd:Q9439)}
VALUES (?property) {(wdt:P22)}
?queenVictoria ?property ?father.
?fatherProperty wikibase:directClaim ?property
SERVICE wikibase:label { bd:serviceParam wikibase:language "fr". }
}

try it!

Import

Virtuoso Import

Ontology

Tools

What Links Here