RDFLib/rdflib-hdt

Filter triples

SRL94 opened this issue · 1 comments

SRL94 commented

Hi,

How could I get triples whose predicates start with a string?
For example,
triples_sub, cardinality_sub = document.search_triples(entity, "http://www.wikidata.org/prop/direct/{}", "")
to get triples whose subject is entity and predicate starts with "http://www.wikidata.org/prop/direct/"

Hi,

You cannot do that with a simple triple matching query, you need to execute a SPARQL query for that. rdflib has a support for executing SPARQL queries, so you can do it with rdflib-hdt too. Here is the related documentation https://rdflib.readthedocs.io/en/stable/intro_to_sparql.html