Modelling/Index term: Difference between revisions

From MetaBase
Jump to navigation Jump to search
No edit summary
No edit summary
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Modelling navigation}}
{{Modelling navigation}}
==Modeling topics==
An '''{{Q|Q12}}''' is a keyword that we use to describe e.g. the topic of a document or the focus area of a project (using {{P|15}}).
An '''{{Q|Q12}}''' is a keyword that we use to describe e.g. the topic of a document or the focus area of a project (using {{P|15}}).


Within the scope of Metabase, the label is enough to tag documents; we do not concern ourselves with e.g. expressing the relationships between index terms. That's why the only the only data we provide is:
Within the scope of Metabase, the label is enough to tag documents; we do not concern ourselves with e.g. expressing the relationships between index terms. Those live in Wikidata, and if necessary, can be queried using federated queries.
 
That's why the only the only data we provide is:


* {{P|P5}} → {{Q|Q12}}
* {{P|P5}} → {{Q|Q12}}
* {{P|P1}} → Q ID  
* {{P|P1}} → Q ID  


For example: {{Q|Q18}}, {{Q|Q39}}, {{Q|Q17}}.
'''For example:''' {{Q|Q18}}, {{Q|Q39}}, {{Q|Q17}}.
 
Of course, sometimes you'll want to use an item that also is something else (e.g. a {{Q|Q66}} or a {{Q|Q22}}) as a topic. In this case, add {{P|P5}} : {{Q|Q12}} to the item.
 
'''For example:''' {{Q|Q21935}}, {{Q|Q26}}.


Query to find all index terms with their labels and descriptions in Swedish and English:
==SPARQL==
===All index terms with their labels and descriptions in Swedish and English===
<SPARQL tryit="1">
<SPARQL tryit="1">
PREFIX wb: <https://metabase.wikibase.cloud/entity/>
PREFIX wb: <https://metabase.wikibase.cloud/entity/>
Line 22: Line 30:
OPTIONAL {?item rdfs:label ?itemLabelSV filter (lang(?itemLabelSV) = "sv")}.
OPTIONAL {?item rdfs:label ?itemLabelSV filter (lang(?itemLabelSV) = "sv")}.
BIND(URI(concat("http://www.wikidata.org/entity/", ?wikidataQ)) AS ?wikidata_iri)
BIND(URI(concat("http://www.wikidata.org/entity/", ?wikidataQ)) AS ?wikidata_iri)
}
</SPARQL>
===Count the index terms===
<SPARQL tryit="1">
PREFIX wb: <https://metabase.wikibase.cloud/entity/>
PREFIX wbt: <https://metabase.wikibase.cloud/prop/direct/>
SELECT (COUNT(*) AS ?count_index_terms)
WHERE
{
?item wbt:P5 wb:Q12 .
}
</SPARQL>
===Timeline of everything published or presented about Structured Data on Commons===
<SPARQL tryit="1">
#defaultView:Timeline
PREFIX wb: <https://metabase.wikibase.cloud/entity/>
PREFIX wbt: <https://metabase.wikibase.cloud/prop/direct/>
SELECT ?item ?itemLabel ?time
WHERE
{
?item wbt:P15 wb:Q90 # SDC
{?item wbt:P23 ?time} # point in time
UNION
{?item wbt:P18 ?time} # publication date
SERVICE wikibase:label { bd:serviceParam wikibase:language "en,sv". }
}
}
</SPARQL>
</SPARQL>
[[Category:Documentation|i]]
[[Category:Documentation|i]]

Latest revision as of 09:04, 19 April 2024


Modeling topics

An index term (Q12) is a keyword that we use to describe e.g. the topic of a document or the focus area of a project (using main subject (P15)).

Within the scope of Metabase, the label is enough to tag documents; we do not concern ourselves with e.g. expressing the relationships between index terms. Those live in Wikidata, and if necessary, can be queried using federated queries.

That's why the only the only data we provide is:

For example: museum collection (Q18), public art (Q39), authority control (Q17).

Of course, sometimes you'll want to use an item that also is something else (e.g. a location (Q66) or a Wikimedia content project (Q22)) as a topic. In this case, add instance of (P5) : index term (Q12) to the item.

For example: Gothenburg (Q21935), Swedish Wikipedia (Q26).

SPARQL

All index terms with their labels and descriptions in Swedish and English

PREFIX wb: <https://metabase.wikibase.cloud/entity/>
PREFIX wbt: <https://metabase.wikibase.cloud/prop/direct/>

SELECT ?item ?itemLabelEN ?itemLabelSV ?wikidata_iri
WHERE
{
?item wbt:P5 wb:Q12 .
OPTIONAL {?item wbt:P1 ?wikidataQ}
OPTIONAL {?item rdfs:label ?itemLabelEN filter (lang(?itemLabelEN) = "en")}.
OPTIONAL {?item rdfs:label ?itemLabelSV filter (lang(?itemLabelSV) = "sv")}.
BIND(URI(concat("http://www.wikidata.org/entity/", ?wikidataQ)) AS ?wikidata_iri)
}

Try it!

Count the index terms

PREFIX wb: <https://metabase.wikibase.cloud/entity/>
PREFIX wbt: <https://metabase.wikibase.cloud/prop/direct/>

SELECT (COUNT(*) AS ?count_index_terms)
WHERE
{
?item wbt:P5 wb:Q12 .
}

Try it!

Timeline of everything published or presented about Structured Data on Commons

#defaultView:Timeline
PREFIX wb: <https://metabase.wikibase.cloud/entity/>
PREFIX wbt: <https://metabase.wikibase.cloud/prop/direct/>
SELECT ?item ?itemLabel ?time
WHERE
{
?item wbt:P15 wb:Q90 # SDC
{?item wbt:P23 ?time} # point in time
UNION
{?item wbt:P18 ?time} # publication date
SERVICE wikibase:label { bd:serviceParam wikibase:language "en,sv". }
}

Try it!