semsol / arc2

ARC RDF Classes for PHP
Other
332 stars 89 forks source link

Named Graph and SPARUL #103

Closed johnss closed 5 years ago

johnss commented 6 years ago

Does this this library support Named graph SPARQL 1.1 Update ?

https://en.m.wikipedia.org/wiki/SPARUL

johnss commented 6 years ago

https://github.com/semsol/arc2/pull/102 doesn't mention anything about named graph https://en.m.wikipedia.org/wiki/Named_graph

bnowack commented 6 years ago

Does https://github.com/semsol/arc2/wiki/SPARQL- help?

ARC2 does not distinguish graphs from named graphs, and the syntax may be out of date, but it is possible to add triples to URI-identified graphs.

k00ni commented 6 years ago

Hi, ARC2 uses a SPARQL syntax which is similar to SPARUL. More information about that in the wiki.

I am the maintainer of Saft, which integrates ARC2. It transforms SPARUL queries such as:

DELETE WHERE {
    Graph <http://localhost/Saft/TestGraph/> {
        ?s ?p ?o .
    }
}

to queries which ARC2 understands, like:

DELETE FROM <http://localhost/Saft/TestGraph/> {
    ?s ?p ?o .
}
WHERE {
    ?s ?p ?o .
}

Maybe it helps.

k00ni commented 6 years ago

Btw. #102 was not about adding new functionality, but to provide a set of tests, checking that a feature is there or missing.

johnss commented 6 years ago

@bnowack I know it can extend triple but I'm not sure it will become 4 statement or 5 statement @k00ni will it become 4 statement or 5 statement

I want the graph to be (subject-predicate-object)-context

I don't want to become subject-predicate-(subject–predicate–object)

k00ni commented 6 years ago

Can you paste some example code? I can't follow you, i am afraid.

johnss commented 6 years ago

My project is i want to create site like wikidata, I don't have a code example as I will probably use php method directly and not using SPARQL.

My question is how your plug in distinguish between named graph or triples added to URI- identified graphs?

Triples added to URI- identified graphs will become 5 node, while true named graph are 4 node, I assume no as Its just a query translator, there's no way to differentiate between named graph or triple added to graph URI

k00ni commented 6 years ago

identified graphs will become 5 node, while true named graph are 4 node, I assume no as Its just a query translator, there's no way to differentiate between named graph or triple added to graph URI

What do you mean by "become 5 node"? ARC2 only knows graphs (with their URI), regardless if named or not in the first place. They are not added as triples, if that is what you meant.

If you are not using SPARQL, how would like to "query" the data? Maybe you want something like this or that?

johnss commented 6 years ago

I already know that arc2 store it several different table, the values of triple stored it in id2val,s2val,o2val, a triples table that link that 3 table together, I don't know what exactly G2T table is used for but I think its used for nesting triple.

Example for 5 node is

Book1 (subject) -> title (predicate) -> example book title (object) And triple that link to book1 as object BookStore (subject) -> Have (predicate) -> [Book1 (subject) -> title (predicate) -> example book title (object)]

A true named graph doesn't need the predicate relation and will look like this BookStore (context) -> [Book1 (subject) -> title (predicate) -> example book title (object)]

The ResourceGuy & Helper and the unit test look the same to me, can you explain the differences?

k00ni commented 6 years ago

@johnss: ResourceGuy basically represents a sub graph, starting by a certain resource. You can access nodes and edges via array-access, like:

$guy = new ResourceGuy();
$anotherGuy = new ResourceGuy();

// storing
$guy['foaf:name'] = $nodeFactory->createLiteral('Mister X');
$guy['foaf:knows'] = $anotherGuy; // ResourceGuy

// getting
$guy['foaf:name'] = $nodeFactory->createLiteral('Mister X');
echo $guy['foaf:name'];

// set and get URI of the ResourceGuy instance
$guy['_idUri'] = $nodeFactory->createNamedNode('http://uri/');
echo $guy['_idUri']->getUri(); // will output a string

ResourceGuyHelper makes it easier to get/create these subgraphs. For instance get all resources of a certain RDF type.

k00ni commented 6 years ago

Can this issue be closed?