Help/Topics

From MetaBase
Jump to navigation Jump to search

About this page

This page explains how to create and use keyword (Q12) items in Metabase.

What is a keyword?

An keyword (Q12) is a keyword. We use keywords with keyword (P15) to describe, for example:

  • what a document is about
  • what a project focuses on

In Metabase, the label is all we need to tag documents. We do not describe how keywords relate to each other, for example which terms are broader or narrower. That information already exists in Wikidata, and you can get it with a federated query if you need it.

Creating a keyword

Before you create a new keyword, search Metabase to check that it does not already exist.

A keyword item only needs a label and these two statements:

Examples:

Using other items as keywords

Sometimes you want to use an item that is already something else as a keyword, for example a location (Q66) or a Wikimedia content project (Q22). You do not need to create a separate keyword item for it. Instead, add one more statement to the existing item:

The item then has two instance of (P5) statements: its original one and keyword (Q12).

Examples:

SPARQL

All keywords, with labels in English and Swedish

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!


Number of keywords

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

This query shows how to use a keyword to find all items about one topic. Replace Q90 with another item to make a timeline for that topic.

#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!