Skip to content

Instantly share code, notes, and snippets.

@corbin-c
Created August 19, 2026 11:24
Show Gist options
  • Select an option

  • Save corbin-c/cd1e4b7d337340bac971d4ba4734e5b5 to your computer and use it in GitHub Desktop.

Select an option

Save corbin-c/cd1e4b7d337340bac971d4ba4734e5b5 to your computer and use it in GitHub Desktop.
Federated Query
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX marcrel: <http://id.loc.gov/vocabulary/relators/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
SELECT distinct ?aut ?auturi
WHERE {
{
SELECT distinct ?auturi ?aut
(GROUP_CONCAT(DISTINCT ?ids_clean; SEPARATOR=" | ") AS ?all_ids_clean)
WHERE {
BIND(<http://www.idref.fr/139753753/id> as ?idref)
{
?uri ?rel ?idref.
?uri ?relcontrib ?auturi.
OPTIONAL {
?uri dcterms:bibliographicCitation ?title.
}
?rel skos:prefLabel ?role.
?auturi a foaf:Person.
?auturi skos:prefLabel ?aut.
FILTER (?auturi != ?idref)
OPTIONAL {
?auturi owl:sameAs ?ids.
}
BIND(COALESCE(?ids, CONCAT("No ID: ", ?auturi)) AS ?ids_clean)
} UNION {
?idref owl:sameAs ?id.
FILTER (CONTAINS(STR(?id), "archives-ouvertes.fr"))
BIND(URI(REPLACE(STR(?id), "#.*", "")) as ?idHal)
SERVICE <http://sparql.archives-ouvertes.fr/sparql> {
?idHal foaf:publications ?uri.
?auturi foaf:publications ?uri.
OPTIONAL {
?uri dcterms:hasVersion ?doc.
?doc dcterms:title ?title.
}
?auturi foaf:name ?aut.
FILTER (?idHal != ?auturi)
OPTIONAL {
?auturi owl:sameAs ?ids.
}
BIND(COALESCE(?ids, CONCAT("No ID: ", ?auturi)) AS ?ids_clean)
}
} UNION {
SERVICE <http://data.persee.fr/sparql> {
?person owl:sameAs ?idref.
?uri ?rel ?person.
?uri ?relcontrib ?auturi.
?uri dcterms:bibliographicCitation ?title.
?auturi a foaf:Person.
?auturi foaf:name ?aut.
FILTER (?auturi != ?person)
OPTIONAL {
?auturi owl:sameAs ?ids.
}
BIND(COALESCE(?ids, CONCAT("No ID: ", ?auturi)) AS ?ids_clean)
}
}
} #GROUP BY ?aut ?auturi
}
{
?auturi a foaf:Person.
OPTIONAL {
?auturi owl:sameAs ?sameas.
}
BIND(COALESCE(?sameas, CONCAT("No ID: ", ?auturi)) AS ?same_as)
}
UNION {
SERVICE <http://sparql.archives-ouvertes.fr/sparql> {
?auturi a foaf:Person.
OPTIONAL {
?auturi owl:sameAs ?sameas.
}
BIND(COALESCE(?sameas, CONCAT("No ID: ", ?auturi)) AS ?same_as)
}
}
UNION {
SERVICE <http://data.persee.fr/sparql> {
?auturi a foaf:Person.
OPTIONAL {
?auturi owl:sameAs ?sameas.
}
BIND(COALESCE(?sameas, CONCAT("No ID: ", ?auturi)) AS ?same_as)
}
}
filter(contains(?all_ids_clean, str(?same_as)))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment