[Nepomuk] Issues with NegationTerm+ComparisonTerm::setInverted

Sebastian Trüg trueg at kde.org
Tue May 18 16:14:58 CEST 2010


Hi Dario,

why would it be "FILTER(!BOUND(?v2))"?
I think the query is correct. Let's only look at the interesting part:

ComparisonTerm nopcTerm(Nepomuk::Vocabulary::NCO::hasIMAccount(),
        ResourceTypeTerm(Nepomuk::Vocabulary::NCO::PersonContact()));
nopcTerm.setInverted(true);

matches all resources that are the im account of a person contact.
If you negate that you would mean all resources that are NOT the im
account of a person contact.

Now let's look at the resulting SPARQL:

[select ?r where ]
OPTIONAL {
  ?v2 nco:hasIMAccount ?v1 .
  ?v2 a ?v3 .
  ?v3 rdfs:subClassOf nco:PersonContact .
  FILTER(?v1=?r) .
} .
FILTER(!BOUND(?v1)) .

The query looks for a ?v1 which is the im account of something that is a
person contact. Then it makes sure that this ?v1 is in fact our ?r and
then it wants this ?v1 not to be bound. In other words it would only
match if ?r is in fact NOT the im account of some person contact.

Cheers,
Sebastian

On 05/18/2010 03:06 PM, Dario Freddi wrote:
> Hello all,
> 
> given the following query:
> 
> ComparisonTerm accountTerm(Nepomuk::Vocabulary::NCO::hasIMAccount(),
> ResourceTerm(mePersonContact));
> 
> accountTerm.setInverted(true);
> 
> ComparisonTerm nopcTerm(Nepomuk::Vocabulary::NCO::hasIMAccount(),
> 
> ResourceTypeTerm(Nepomuk::Vocabulary::NCO::PersonContact()));
> 
> nopcTerm.setInverted(true);
> 
> OrTerm condterm(accountTerm, NegationTerm::negateTerm(nopcTerm));
> 
> // Match the ID
> 
> ComparisonTerm pathTerm(Nepomuk::Vocabulary::Telepathy::accountIdentifier(),
> 
> LiteralTerm(m_path), Nepomuk::Query::ComparisonTerm::Equal);
> 
> Query query(AndTerm(condterm, pathTerm,
> 
> ResourceTypeTerm(Nepomuk::Vocabulary::NCO::IMAccount())));
> 
> query.toSparqlQuery gives:
> 
> "select distinct ?r
> where { { { <nepomuk:/res/5dcd4fcd-6305-4b1d-b085-6ff52971ebc8>
> <http://www.semanticdesktop.org/ontologies/2007/03/22/nco#hasIMAccount>
> ?r . } UNION { OPTIONAL { ?v2
> <http://www.semanticdesktop.org/ontologies/2007/03/22/nco#hasIMAccount>
> ?v1 . ?v2 a ?v3 . ?v3 <http://www.w3.org/2000/01/rdf-schema#subClassOf>
> <http://www.semanticdesktop.org/ontologies/2007/03/22/nco#PersonContact>
> . FILTER(?v1=?r) . } . FILTER(!BOUND(?v1)) . } . ?r
> <http://nepomuk.kde.org/ontologies/2009/06/20/telepathy#accountIdentifier>
> "/my/account/path"^^<http://www.w3.org/2001/XMLSchema#string> . ?r a ?v4
> . ?v4 <http://www.w3.org/2000/01/rdf-schema#subClassOf>
> <http://www.semanticdesktop.org/ontologies/2007/03/22/nco#IMAccount>
> . } . }"
> 
> After some thinking, we came to the conclusion that it should be
> FILTER(!BOUND(?v2)) instead of FILTER(!BOUND(?v1)). Is it possible that
> NegationTerm ignores the inversion of the comparison term?
> 
> -- 
> 
> -------------------
> 
> Dario Freddi
> 
> KDE Developer
> 
> GPG Key Signature: 511A9A3B
> 
> 
> 
> _______________________________________________
> Nepomuk mailing list
> Nepomuk at kde.org
> https://mail.kde.org/mailman/listinfo/nepomuk


More information about the Nepomuk mailing list