query-a54070470f93a17c8fba4e007d43e453

rq turtle/ttl

Migrating from MAGAs you see above, there are 273k MAG IDs that could be migrated to OpenAlex. I agree with Egon that OpenAlex IDs will diverge from MAG IDs in the future, but I think that right now it makes sense to do this migration. I hoped it should be straightforward to populate from existing MAG values by prepending a letter depending on the item type: if Human then A, if Organization then I, etc. This query counts type combinations of items with MAG. It times out on WD, so I ran it on a local instance

Use at

PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
select ?A ?I ?V ?W ?letters (count(*) as ?c) {
  ?x wdt:P6366 ?mag
  bind(exists {?x wdt:P31/wdt:P279* wd:Q5} as ?A)
  bind(exists {?x wdt:P31/wdt:P279* wd:Q43229} as ?I)
  bind(exists {?x wdt:P31/wdt:P279* wd:Q5633421}|| exists {?x wdt:P31/wdt:P279* wd:Q625994} as ?V)
  bind(exists {?x wdt:P31/wdt:P279* wd:Q17537576} as ?W)
  bind(if(?A,1,0) as ?cA)
  bind(if(?I,1,0) as ?cI)
  bind(if(?V,1,0) as ?cV)
  bind(if(?W,1,0) as ?cW)
  bind(?cA+?cI+?cV+?cW as ?letters)
} group by ?A ?I ?V ?W ?letters

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v3("?A"):::projected v4("?I"):::projected v5("?V"):::projected v6("?W"):::projected v12("?c") v7("?cA") v8("?cI") v9("?cV") v10("?cW") v11("?letters"):::projected v2("?mag") v1("?x") v1 --"wdt:P6366"--> v2 v1 --"wdt:P31"--> null null --"wdt:P279"--> null bind0[/" "/] subgraph bind0e0["Exists Clause"] e0v1 --"wdt:P31"--> e0a1 e0a1 --"wdt:P279"--> e0c3 e0v1("?x"):::projected e0a1((" ")):::projected e0c3(["wd:Q5"]):::iri end bind0--EXISTS--> bind0e0 v1 --o bind0 null --o bind0 null --o bind0 null --o bind0 null --o bind0 bind0 --as--o v3 v1 --"wdt:P31"--> null null --"wdt:P279"--> null bind1[/" "/] subgraph bind1e1["Exists Clause"] e1v1 --"wdt:P31"--> e1a1 e1a1 --"wdt:P279"--> e1c3 e1v1("?x"):::projected e1a1((" ")):::projected e1c3(["wd:Q43229"]):::iri end bind1--EXISTS--> bind1e1 v1 --o bind1 null --o bind1 null --o bind1 null --o bind1 null --o bind1 bind1 --as--o v4 v1 --"wdt:P31"--> null null --"wdt:P279"--> null v1 --"wdt:P31"--> null null --"wdt:P279"--> null bind2[/"( || )"/] subgraph bind2e2["Exists Clause"] e2v1 --"wdt:P31"--> e2a1 e2a1 --"wdt:P279"--> e2c3 e2v1("?x"):::projected e2a1((" ")):::projected e2c3(["wd:Q5633421"]):::iri end bind2--EXISTS--> bind2e2 subgraph bind2e3["Exists Clause"] e3v1 --"wdt:P31"--> e3a1 e3a1 --"wdt:P279"--> e3c3 e3v1("?x"):::projected e3a1((" ")):::projected e3c3(["wd:Q625994"]):::iri end bind2--EXISTS--> bind2e3 v1 --o bind2 null --o bind2 null --o bind2 null --o bind2 null --o bind2 null --o bind2 null --o bind2 bind2 --as--o v5 v1 --"wdt:P31"--> null null --"wdt:P279"--> null bind3[/" "/] subgraph bind3e4["Exists Clause"] e4v1 --"wdt:P31"--> e4a1 e4a1 --"wdt:P279"--> e4c3 e4v1("?x"):::projected e4a1((" ")):::projected e4c3(["wd:Q17537576"]):::iri end bind3--EXISTS--> bind3e4 v1 --o bind3 null --o bind3 null --o bind3 null --o bind3 null --o bind3 bind3 --as--o v6 bind4[/"if(?A,'1^^xsd:integer','0^^xsd:integer')"/] v3 --o bind4 bind4 --as--o v7 bind5[/"if(?I,'1^^xsd:integer','0^^xsd:integer')"/] v4 --o bind5 bind5 --as--o v8 bind6[/"if(?V,'1^^xsd:integer','0^^xsd:integer')"/] v5 --o bind6 bind6 --as--o v9 bind7[/"if(?W,'1^^xsd:integer','0^^xsd:integer')"/] v6 --o bind7 bind7 --as--o v10 bind8[/"?cA + ?cI + ?cV + ?cW"/] v7 --o bind8 v8 --o bind8 v9 --o bind8 v10 --o bind8 bind8 --as--o v11 bind10[/"count(*)"/] bind10 --as--o v12