Please help out a sparql newbie!
I have the following query to select identifiers for BHL Titles:
SELECT DISTINCT ?TitleID ?Wikidata ?OCLC ?ISSN ?Linking_ISSN ?ISBN13 ?ISBN10 ?Coden ?DLC ?NLM ?TL2 ?DOI WHERE { SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". } { SELECT DISTINCT ?item WHERE { ?item p:P4327 ?statement0. ?statement0 ps:P4327 _:anyValueP4327. } } BIND(REPLACE(STR(?item), "http://www.wikidata.org/entity/", "") AS ?Wikidata ) OPTIONAL { ?item wdt:P4327 ?TitleID. } OPTIONAL { ?item wdt:P243 ?OCLC. } OPTIONAL { ?item wdt:P236 ?ISSN. } OPTIONAL { ?item wdt:P7363 ?Linking_ISSN. } OPTIONAL { ?item wdt:P212 ?ISBN13. } OPTIONAL { ?item wdt:P957 ?ISBN10. } OPTIONAL { ?item wdt:P1159 ?Coden. } OPTIONAL { ?item wdt:P244 ?DLC. } OPTIONAL { ?item wdt:P1055 ?NLM. } OPTIONAL { ?item wdt:P5878 ?TL2. } OPTIONAL { ?item wdt:P356 ?DOI. } }
It seems to work, as it returns about 170K unique identifiers for about 64K titles.
However, after adding those identifiers to a BHL database table where I could compare the data to what is already in BHL, I found that some items are missing from the sparql result.
For example, Q51512257 is associated with BHL Title 88, Q54792313 with BHL TItle 100, and Q51399752 with BHL Title 1231. The query above does not return any of those wikidata items. I modified the query to return just one of those wikidata items...
SELECT DISTINCT ?item ?TitleID ?Wikidata ?OCLC ?ISSN ?Linking_ISSN ?ISBN13 ?ISBN10 ?Coden ?DLC ?NLM ?TL2 ?DOI WHERE { BIND(wd:Q51512257 AS ?item) SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". } BIND(REPLACE(STR(?item), "http://www.wikidata.org/entity/", "") AS ?Wikidata ) OPTIONAL { ?item wdt:P4327 ?TitleID. } OPTIONAL { ?item wdt:P243 ?OCLC. } OPTIONAL { ?item wdt:P236 ?ISSN. } OPTIONAL { ?item wdt:P7363 ?Linking_ISSN. } OPTIONAL { ?item wdt:P212 ?ISBN13. } OPTIONAL { ?item wdt:P957 ?ISBN10. } OPTIONAL { ?item wdt:P1159 ?Coden. } OPTIONAL { ?item wdt:P244 ?DLC. } OPTIONAL { ?item wdt:P1055 ?NLM. } OPTIONAL { ?item wdt:P5878 ?TL2. } OPTIONAL { ?item wdt:P356 ?DOI. } }
... and it did return the item, but no identifier values. Viewing https://www.wikidata.org/wiki/Q51512257 shows that the item does in fact have a DOI, BHL Bibliography ID (Title ID), and OCLC Control Number.
So, what is going wrong? Is there something wrong with my query, or is there something unusual about those items? (Or, I guess... both... is there something unusual that my query is not accounting for?)
Thanks in advance!
MIKE