Behind the <P812 : academic major> Property
This morning, I stumbled upon this Wikidata error.
I wanted to fix it, but I did not know how.
I wish there were an "intelligent autocorrect" feature built into Wikidata that could suggest a quick fix for situations like this. Modern IDEs already have such features.
Anyway. So, I started thinking of several ways to solve the problem.
One of my proposed solutions was to do a quick “global survey of Wikidata-wide usage” of P812 (academic major). Generate a list of all possible "legal" values of P812, then sort them by frequency.
So, I crafted this SPARQL query.
SELECT ?major ?majorLabel (COUNT(*) AS ?count)
WHERE {
?item wdt:P812 ?major .
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en,mul,[AUTO_LANGUAGE]" .
}
}
GROUP BY ?major ?majorLabel
ORDER BY DESC(?count)Using that SPARQL query, I could generate this list.
Satisfactory?
No.
I felt something big was missing.
That query only counted direct statements.
person → P812 → English literatureI also needed to count the other case.
person → P69 → St John's College
└── qualifier: P812 = English literatureSo, I crafted another SPARQL query.
SELECT ?major ?majorLabel (COUNT(*) AS ?count)
WHERE {
{
?item wdt:P812 ?major .
}
UNION
{
?item p:P69 ?educationStatement .
?educationStatement pq:P812 ?major .
}
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en,mul,[AUTO_LANGUAGE]" .
}
}
GROUP BY ?major ?majorLabel
ORDER BY DESC(?count)But the Wikidata Query Service failed to execute it due to an upstream request timeout.
So, I modified the SPARQL query so it could be executed in QLever.
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?major ?majorLabel (COUNT(*) AS ?count)
WHERE {
{
?item wdt:P812 ?major .
}
UNION
{
?item p:P69 ?educationStatement .
?educationStatement pq:P812 ?major .
}
OPTIONAL {
?major rdfs:label ?majorLabel .
FILTER(LANG(?majorLabel) = "en")
}
}
GROUP BY ?major ?majorLabel
ORDER BY DESC(?count)It worked.
Now, I can simply browse that list to see what kinds of "academic major" values are considered valid to enter into Wikidata.




