[Python] Federated Query between two RDFlib graphs

Discussão em 'Python' iniciado por Stack, Outubro 23, 2024.

  1. Stack

    Stack Membro Participativo

    I have two local knowledge graphs in the form of turtle files.

    Let's say they look something like: File1 - people.ttl

    Bob a person ;
    feeds cat-1 ;
    trains dog-1 ;
    owns house-1 .


    File 2 - houses.ttl

    house-1 a house ;
    worth "$500k" ;
    has_address "123 Road Dr." .


    if I load these into rdflib as pplGraph and hsGraph:

    from rdflib import Graph

    pplGraph = Graph().parse('people.ttl')
    hsGraph = Graph().parse('houses.ttl')


    is there a way to do a federated query between them? Say I want to know the cost of every person's house, how would I write that query?

    I know I could do something like:

    for s,p,o in hsGraph.triples((None, None, None)):
    pplGraph.add((s,p,o))


    and then do a non-federated query, but is it possible to keep the two separate and just use the query method?

    Continue reading...

Compartilhe esta Página