[Nepomuk] Issues with NegationTerm+ComparisonTerm::setInverted
Dario Freddi
drf54321 at gmail.com
Tue May 18 16:27:39 CEST 2010
Hi Sebastian,
On Tuesday 18 May 2010 16:14:58 Sebastian Trüg wrote:
> 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.
I see - this actually makes more sense. I thought the match was on the
PersonContact which owns a specific IMAccount - given that we wanted to match
an IMAccount which was NOT an imaccount of a personcontact. I fell into a
stupid logical error, sorry for the noise :)
>
> 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?
>
> _______________________________________________
> Nepomuk mailing list
> Nepomuk at kde.org
> https://mail.kde.org/mailman/listinfo/nepomuk
--
-------------------
Dario Freddi
KDE Developer
GPG Key Signature: 511A9A3B
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
Url : http://mail.kde.org/pipermail/nepomuk/attachments/20100518/34583f42/attachment.sig
More information about the Nepomuk
mailing list