Hi Barry,

Sorry, no, there isn't.

SSE started out for is for SPARQL and SPARQL does not have ANY, it has named variables.

You can

SSE.parse("(:s :p ANY)")

to get back an Item then copy/modify the BuilderGraph/BuilderNode code.

    Andy


On 14/05/18 14:08, Nouwt, B. (Barry) wrote:
Hi Andy,



Regarding the SSE.parseTriple(…) method; how do I parse an ANY Node? I would 
expect something like the following exists, but I cannot find how to do it:



SSE.parseTriple(“(test:subj test:pred ANY)”);



Regards, Barry

Verzonden vanaf mijn Windows 10-telefoon

Van: Andy Seaborne<mailto:a...@apache.org>
Verzonden: maandag 14 mei 2018 13:33
Aan: Nouwt, B. (Barry)<mailto:barry.no...@tno.nl>
Onderwerp: Re: parsing and matching triples



Barry - could you send questions to the list please?

Thanks
Andy

On 14/05/18 06:50, Nouwt, B. (Barry) wrote:

Hi Andy,



Regarding the SSE.parseTriple(…) method; how do I parse an ANY Node? I would 
expect something like the following exists, but I cannot find how to do it:



SSE.parseTriple(“(test:subj test:pred ANY)”);



Regards, Barry



Van: Andy Seaborne<mailto:a...@apache.org>
Verzonden: dinsdag 8 mei 2018 17:51
Aan: users@jena.apache.org<mailto:users@jena.apache.org>
Onderwerp: Re: parsing and matching triples



Barry,

As a general concept "matching" happens at different levels.

Triple.match corresponds to the matching done by Graph.find - RDF terms
(URI, bnode, literal) match exactly, and Node.ANY is a wildcard.

Triple t1 = Triple.ANY;
Triple t2 = SSE.parseTriple("(:s :p :o)");
   t1.matches(t2) -> true
   t2.matches(t1) -> false

Variables are a concept for SPARQL - and matches usefully need to return
which variable matched which RDF Term.

Triple patterns match against graphs and return an iterator of ways they
match.

Consider cases like "?x ?p ?x" where the variables impose am additional
shape.

If you want variable bindings, you could build a SPARQL query or wrap up
some of the internal code e.g.

/** Evaluate a triple pattern */
private static QueryIterator match(Graph source, Triple pattern) {
      ExecutionContext execContext =
            new ExecutionContext(ARQ.getContext(), source, null, null) ;
      QueryIterator chain = QueryIterRoot.create(execContext)
      chain = new QueryIterTriplePattern(chain, pattern, execContext) ;
      return chain ;
}

      Andy

On 08/05/18 09:21, Nouwt, B. (Barry) wrote:
Hi everybody,

I’m trying to reuse Apache Jena code that parses and matches triples. I’m 
currently looking at the SSE class’s parseTriple() method. This seems to fit my 
purpose for parsing a string representation of a triple into a triple object. I 
also noticed the following Javadoc on the Node.maches(Node) method:

Answer true iff this node accepts the other one as a match.
The default is an equality test; it is over-ridden in subclasses to
provide the appropriate semantics for literals, ANY, and variables.

Since this is exactly what I’m looking for, I’ve tried to match two triples 
using the matches() method, but it does not seem to work:

Triple t1 = SSE.parseTriple("(?s ?p ?o)");
Triple t2 = SSE.parseTriple("(test:subject test:predicate test:object)", pm);
t1.matches(t2)

The final statement returns false, while I would expect it to return true. 
Either, I’m missing something (which is completely realistic 😊), or I should 
use some other method to match two triples in the way described above.

Any help is appreciated!

Regards, Barry
This message may contain information that is not intended for you. If you are 
not the addressee or if this message was sent to you by mistake, you are 
requested to inform the sender and delete the message. TNO accepts no liability 
for the content of this e-mail, for the manner in which you use it and for 
damage of any kind resulting from the risks inherent to the electronic 
transmission of messages.


Reply via email to