-
Notifications
You must be signed in to change notification settings - Fork 580
Closed
Labels
enhancementNew feature or requestNew feature or request
Milestone
Description
When calling the Graph method subjects or predicates, the generator should only return unique values. For example:
from rdflib import Graph
graph = Graph()
graph.parse("https://www.w3.org/People/Berners-Lee/card")
list(graph.subjects())returns the following:
[rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card'),
rdflib.term.BNode('N170b6415b06f45c98cb7a09398bbe818'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card#i'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card#i'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card#i'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card#i'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card#i'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card#i'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card#i'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card#i'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card#i'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card#i'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card#i'),
rdflib.term.URIRef('http://www.w3.org/data#W3C'),
rdflib.term.URIRef('http://www.ecs.soton.ac.uk/~dt2/dlstuff/www2006_data#panel-panelk01'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card#i'),
rdflib.term.URIRef('http://wiki.ontoworld.org/index.php/_IRW2006'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card#i'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card#i'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card#i'),
rdflib.term.URIRef('http://www.w3.org/2011/Talks/0331-hyderabad-tbl/data#talk'),
rdflib.term.BNode('Nb0ee70dcdcc042609d1dde9df6b9efd5'),
rdflib.term.BNode('Nebae90d841e441adbf72a3836347c354'),
rdflib.term.URIRef('https://timbl.com/timbl/Public/friends.ttl'),
rdflib.term.URIRef('http://www.w3.org/People/Berners-Lee/card#i'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card#i'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card#i'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card#i'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card#i'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card#i'),
rdflib.term.URIRef('http://dig.csail.mit.edu/breadcrumbs/blog/4'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card'),
rdflib.term.BNode('N112689303c124871942e42a7ded52e64'),
rdflib.term.BNode('N112689303c124871942e42a7ded52e64'),
rdflib.term.URIRef('http://dig.csail.mit.edu/data#DIG'),
rdflib.term.URIRef('https://www.w3.org/DesignIssues/Overview.html'),
rdflib.term.URIRef('http://dig.csail.mit.edu/2007/01/camp/data#course'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card#i'),
rdflib.term.URIRef('https://timbl.com/timbl/Public/friends.ttl'),
rdflib.term.BNode('Nebae90d841e441adbf72a3836347c354'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card#i'),
rdflib.term.URIRef('https://timbl.com/timbl/Public/friends.ttl'),
rdflib.term.BNode('Nce03d86469d64deb945313ef31a8e661'),
rdflib.term.BNode('Nce03d86469d64deb945313ef31a8e661'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card#i'),
rdflib.term.BNode('N1d372c7ed22e4de5a167177739cc29a0'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card#i'),
rdflib.term.URIRef('https://www.w3.org/DesignIssues/Overview.html'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card#i'),
rdflib.term.BNode('N112689303c124871942e42a7ded52e64'),
rdflib.term.URIRef('https://timbl.com/timbl/Public/friends.ttl'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card#i'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card#i'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card#i'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card#i'),
rdflib.term.URIRef('http://www.w3.org/2011/Talks/0331-hyderabad-tbl/data#talk'),
rdflib.term.URIRef('http://www.w3.org/2000/10/swap/data#Cwm'),
rdflib.term.URIRef('http://dig.csail.mit.edu/breadcrumbs/blog/4'),
rdflib.term.URIRef('http://wiki.ontoworld.org/index.php/_IRW2006'),
rdflib.term.URIRef('https://timbl.com/timbl/Public/friends.ttl'),
rdflib.term.URIRef('http://www.ecs.soton.ac.uk/~dt2/dlstuff/www2006_data#panel-panelk01'),
rdflib.term.BNode('N170b6415b06f45c98cb7a09398bbe818'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card#i'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card#i'),
rdflib.term.BNode('Nce03d86469d64deb945313ef31a8e661'),
rdflib.term.BNode('Nb0ee70dcdcc042609d1dde9df6b9efd5'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card#i'),
rdflib.term.BNode('Nebae90d841e441adbf72a3836347c354'),
rdflib.term.BNode('N713bca5215e14aa4ae1a3dfca525ce37'),
rdflib.term.BNode('N1d372c7ed22e4de5a167177739cc29a0'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card#i'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card#i'),
rdflib.term.BNode('N713bca5215e14aa4ae1a3dfca525ce37'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card#i'),
rdflib.term.BNode('N112689303c124871942e42a7ded52e64'),
rdflib.term.URIRef('http://dig.csail.mit.edu/breadcrumbs/blog/4'),
rdflib.term.URIRef('http://dig.csail.mit.edu/2005/ajar/ajaw/data#Tabulator'),
rdflib.term.BNode('N112689303c124871942e42a7ded52e64'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card#i'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card#i'),
rdflib.term.BNode('N1d372c7ed22e4de5a167177739cc29a0'),
rdflib.term.BNode('N1d372c7ed22e4de5a167177739cc29a0'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card#i'),
rdflib.term.BNode('N1d372c7ed22e4de5a167177739cc29a0')]
I would expect it to return something more along the lines of:
[rdflib.term.URIRef('http://www.ecs.soton.ac.uk/~dt2/dlstuff/www2006_data#panel-panelk01'),
rdflib.term.URIRef('http://dig.csail.mit.edu/data#DIG'),
rdflib.term.URIRef('http://www.w3.org/2000/10/swap/data#Cwm'),
rdflib.term.URIRef('http://dig.csail.mit.edu/2005/ajar/ajaw/data#Tabulator'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card'),
rdflib.term.URIRef('http://www.w3.org/People/Berners-Lee/card#i'),
rdflib.term.BNode('N170b6415b06f45c98cb7a09398bbe818'),
rdflib.term.BNode('N1d372c7ed22e4de5a167177739cc29a0'),
rdflib.term.URIRef('http://wiki.ontoworld.org/index.php/_IRW2006'),
rdflib.term.BNode('N112689303c124871942e42a7ded52e64'),
rdflib.term.URIRef('https://www.w3.org/DesignIssues/Overview.html'),
rdflib.term.BNode('N713bca5215e14aa4ae1a3dfca525ce37'),
rdflib.term.URIRef('http://www.w3.org/data#W3C'),
rdflib.term.BNode('Nce03d86469d64deb945313ef31a8e661'),
rdflib.term.URIRef('http://dig.csail.mit.edu/2007/01/camp/data#course'),
rdflib.term.BNode('Nebae90d841e441adbf72a3836347c354'),
rdflib.term.URIRef('http://www.w3.org/2011/Talks/0331-hyderabad-tbl/data#talk'),
rdflib.term.BNode('Nb0ee70dcdcc042609d1dde9df6b9efd5'),
rdflib.term.URIRef('https://www.w3.org/People/Berners-Lee/card#i'),
rdflib.term.URIRef('https://timbl.com/timbl/Public/friends.ttl'),
rdflib.term.URIRef('http://dig.csail.mit.edu/breadcrumbs/blog/4')]
While you could technically get the list of unique subjects using list(set(graph.subjects())) it would be nice if subjects did this automatically.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request