I understand.

The resoluton seems:

  *   Use same objectvars in case of ‘no optionals’
  *   In case of ‘optionals’ you get matches that way that are not intended
  *   In the latter case use filters (the result is as intended since ‘no 
value’ and ‘a value’ do not match….)

The filters work fine now it seems, thx, Michel



Dr. ir. H.M. (Michel) Bohms
Scientist Specialist
Structural Reliability

T +31 (0)88 866 31 07
M +31 (0)63 038 12 20
E michel.bo...@tno.nl<mailto:michel.bo...@tno.nl>

Location<http://www.tno.nl/locations/DTS>



[cid:image001.gif@01D7E2B5.E5626DB0]<http://www.tno.nl/>

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.




From: topbraid-users@googlegroups.com <topbraid-users@googlegroups.com> On 
Behalf Of Irene Polikoff
Sent: Friday 26 November 2021 10:57 AM
To: topbraid-users@googlegroups.com
Subject: Re: [topbraid-users] sparql question

Sorry, we can’t really get involved in debugging complex queries.

In general, using a filter in these situations should be unnecessary and is an 
anti-pattern since the query engine needs to pick all triples and then filter. 
It is much better to use the same variables.

The way OPTIONAL and FILTER are combined in this example does not make sense to 
me.  For example, you say that mengselType1 must be bound but mengselType2 can 
be unbound, but then you use FILTER to check that they are the same.



On Nov 25, 2021, at 2:51 PM, 'Bohms, H.M. (Michel)' via TopBraid Suite Users 
<topbraid-users@googlegroups.com<mailto:topbraid-users@googlegroups.com>> wrote:

Hu Holger,

It seems that only having ‘multiple object variables + filters’ gives the right 
result.

So:

SELECT ?spec ?bpsWeg1 ?mengselType1 ?bpsStartKilometrering1 ?eisvoormengseltype 
?minhol ?maxhol ?eiszeef2 ?eiszeef0dot063 ?minbind ?monster ?locatie 
?monsterLaag ?laag ?bitumenSoort ?verdichtingsgraad ?holleruimtePercentage 
?bindmiddelPercentage ?doorZeef2millimPercentage ?doorZeef63micromPercentage 
?jaar ?somVanRafeling
{
  ?spec rdf:type sa:OntwerpSpecificatie .
  ?spec sa:bpsWeg ?bpsWeg .
  ?spec sa:mengselVoldoetAanDeEisenVoor ?eisvoormengseltype .
  ?spec sa:minimumPercentageHolleRuimte ?minhol .
  ?spec sa:maximumPercentageHolleRuimte ?maxhol .
  ?spec sa:algemeneEisPercentageDoorZeef2mm ?eiszeef2 .
  ?spec sa:algemeneEisPercentageDoorZeef0dot063mm ?eiszeef0dot063 .
  ?spec sa:minimalePercentageBindmiddel ?minbind .
  ?monster rdf:type sa:Monster .
  ?monster sa:bpsWeg ?bpsWeg1 .
  OPTIONAL { ?monster sa:bpsStartKilometrering ?bpsStartKilometrering1 } .
  ?monster sa:locatie ?locatie .
  ?monster nen2660:hasPart ?monsterLaag .
  ?monsterLaag rdf:type sa:MonsterLaag .
  ?monsterLaag sa:mengselType ?mengselType1 .
  ?monsterLaag sa:laag ?laag .
  ?monsterLaag sa:bitumenSoort ?bitumenSoort .
  OPTIONAL { ?monsterLaag sa:verdichtingsgraad ?verdichtingsgraad } .
  OPTIONAL { ?monsterLaag sa:holleruimtePercentage ?holleruimtePercentage } .
  OPTIONAL { ?monsterLaag sa:bindmiddelPercentage ?bindmiddelPercentage } .
  OPTIONAL { ?monsterLaag sa:doorZeef2millimPercentage 
?doorZeef2millimPercentage } .
  OPTIONAL { ?monsterLaag sa:doorZeef63micromPercentage 
?doorZeef63micromPercentage } .
  ?meting rdf:type sa:MonitoringMeting .
  OPTIONAL { ?meting sa:surfaceOmschrijving ?mengselType2 } .
  ?meting sa:jaar ?jaar .
  ?meting sa:bpsWeg ?bpsWeg2 .
  ?meting sa:bpsStartKilometrering ?bpsStartKilometrering2 .
  OPTIONAL { ?meting sa:somVanRafeling ?somVanRafeling } .
  FILTER (?mengselType1 = ?mengselType2) .
  FILTER (?bpsWeg1 = ?bpsWeg2) .
  FILTER (?bpsStartKilometrering1 = ?bpsStartKilometrering2) .
}

So, the red way gives the right results.

The result where there is only one ?bpsWeg, one ?bpsMengselType en one 
?bpsStartKilometring without filter gives many unwanted results.

I thought it would be equivalent. Guess not….(maybe related to optional 
attributes?)

Gr Michel



Dr. ir. H.M. (Michel) Bohms
Scientist Specialist
Structural Reliability

T +31 (0)88 866 31 07
M +31 (0)63 038 12 20
E michel.bo...@tno.nl<mailto:michel.bo...@tno.nl>

Location<http://www.tno.nl/locations/DTS>



<http://www.tno.nl/>
<image001.gif><http://www.tno.nl/>


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.




From: Bohms, H.M. (Michel)
Sent: Thursday 25 November 2021 7:31 PM
To: 'topbraid-users@googlegroups.com' 
<topbraid-users@googlegroups.com<mailto:topbraid-users@googlegroups.com>>
Subject: RE: [topbraid-users] sparql question

Yes it was ☹

Still a lot of (now changed) results that I have to check….

Can I derive that it should work in the end using this approach (involving a 
common object variable)?
Ie I do not need to use multiple variables and then FILTER them out based on 
equalness?

Thx Michel




Dr. ir. H.M. (Michel) Bohms
Scientist Specialist
Structural Reliability

T +31 (0)88 866 31 07
M +31 (0)63 038 12 20
E michel.bo...@tno.nl<mailto:michel.bo...@tno.nl>

Location<http://www.tno.nl/locations/DTS>



<http://www.tno.nl/>
<image001.gif><http://www.tno.nl/>


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.




From: topbraid-users@googlegroups.com<mailto:topbraid-users@googlegroups.com> 
<topbraid-users@googlegroups.com<mailto:topbraid-users@googlegroups.com>> On 
Behalf Of Holger Knublauch
Sent: Thursday 25 November 2021 1:53 AM
To: topbraid-users@googlegroups.com<mailto:topbraid-users@googlegroups.com>
Subject: Re: [topbraid-users] sparql question


Is this a typo ?bpsStartkilometrering vs ?bpsStartKilometrering (upper-case K) ?

Holger


On 2021-11-25 6:56 am, 'Bohms, H.M. (Michel)' via TopBraid Suite Users wrote:
When I want to select attributes from different classes (monster & meting) that 
share the value of another attribute (here ‘bpsStartKilometrering’), I now use 
the red below in annex 1.

In the results I however get lines where   ?meting sa:bpsStartKilometrering 
?bpsStartKilometrering . is not satisfied.

The example instance has startKilomtrering 3100 and the year is 2020 and 
sumofrafeling has some values..
But the original measure do not have year/sum for 3100!

So I guess I have to do differently? Like having 2 variables: 
bpsStartKilometrering1 and bpsStartKilometrering2 (one for Monster and one for 
Meting) and then somehow:
bpsStartKilometrering1=bpsStartKilometrering2?

It seems now the result lines become (many) joins of subquestion results per 
class that are not subsetted by using the same variable…

Annex 1 sparql select code

SELECT ?spec ?bpsWeg ?bpsStartkilometrering ?eisvoormengseltype ?minhol ?maxhol 
?eiszeef2 ?eiszeef0dot063 ?minbind ?monster ?locatie ?monsterLaag ?laag 
?bitumenSoort ?verdichtingsgraad ?holleruimtePercentage ?bindmiddelPercentage 
?doorZeef2millimPercentage ?doorZeef63micromPercentage ?jaar ?somVanRafeling
{
  ?spec rdf:type sa:OntwerpSpecificatie .
  ?spec sa:bpsWeg ?bpsWeg .
  ?spec sa:mengselVoldoetAanDeEisenVoor ?eisvoormengseltype .
  ?spec sa:minimumPercentageHolleRuimte ?minhol .
  ?spec sa:maximumPercentageHolleRuimte ?maxhol .
  ?spec sa:algemeneEisPercentageDoorZeef2mm ?eiszeef2 .
  ?spec sa:algemeneEisPercentageDoorZeef0dot063mm ?eiszeef0dot063 .
  ?spec sa:minimalePercentageBindmiddel ?minbind .
  ?monster rdf:type sa:Monster .
  ?monster sa:bpsWeg ?bpsWeg .
  OPTIONAL { ?monster sa:bpsStartKilometrering ?bpsStartkilometrering } .
  ?monster sa:locatie ?locatie .
  ?monster nen2660:hasPart ?monsterLaag .
  ?monsterLaag rdf:type sa:MonsterLaag .
  ?monsterLaag sa:mengselType "SMA-NL 11B" .
  ?monsterLaag sa:laag ?laag .
  ?monsterLaag sa:bitumenSoort ?bitumenSoort .
  OPTIONAL { ?monsterLaag sa:verdichtingsgraad ?verdichtingsgraad } .
  OPTIONAL { ?monsterLaag sa:holleruimtePercentage ?holleruimtePercentage } .
  OPTIONAL { ?monsterLaag sa:bindmiddelPercentage ?bindmiddelPercentage } .
  OPTIONAL { ?monsterLaag sa:doorZeef2millimPercentage 
?doorZeef2millimPercentage } .
  OPTIONAL { ?monsterLaag sa:doorZeef63micromPercentage 
?doorZeef63micromPercentage } .
  ?meting rdf:type sa:MonitoringMeting .
  OPTIONAL { ?meting sa:surfaceOmschrijving "SMA-NL 11B" } .
  ?meting sa:jaar ?jaar .
  ?meting sa:bpsWeg ?bpsWeg .
  ?meting sa:bpsStartKilometrering ?bpsStartKilometrering .
  OPTIONAL { ?meting sa:somVanRafeling ?somVanRafeling } .
}

Annex 2 unwanted result (one of many)

   {
      "spec": {
        "uri": https://w3id.org/sa/def#_505007,
        "label": "_505007"
      },
      "bpsWeg": {
        "lex": "N317"
      },
      "bpsStartkilometrering": {
        "lex": "3100",
        "dt": "integer"
      },
      "eisvoormengseltype": {
        "lex": "Sma - NL 11 B 40/60"
      },
      "minhol": {
        "lex": "4.50",
        "dt": "double"
      },
      "maxhol": {
        "lex": "8.00",
        "dt": "double"
      },
      "eiszeef2": {
        "lex": "28.00",
        "dt": "double"
      },
      "eiszeef0dot063": {
        "lex": "7.70",
        "dt": "double"
      },
      "minbind": {
        "lex": "6.4",
        "dt": "double"
      },
      "monster": {
        "uri": https://w3id.org/sa/def#_12A,
        "label": "_12A"
     },
      "locatie": {
        "lex": "km 3.1 6.00m uit LK"
      },
      "monsterLaag": {
        "uri": https://w3id.org/sa/def#_12A1,
        "label": "_12A1"
      },
      "laag": {
        "lex": "1",
        "dt": "integer"
      },
      "bitumenSoort": {
        "lex": "70/100"
      },
      "verdichtingsgraad": null,
      "holleruimtePercentage": {
        "lex": "4.00",
        "dt": "double"
      },
      "bindmiddelPercentage": {
        "lex": "6.50",
        "dt": "double"
      },
      "doorZeef2millimPercentage": {
        "lex": "26.40",
        "dt": "double"
      },
      "doorZeef63micromPercentage": {
        "lex": "8.50",
        "dt": "double"
      },
      "jaar": {
        "lex": "2020",
        "dt": "integer"
      },
      "somVanRafeling": {
        "lex": "4",
        "dt": "integer"
      }
    },



Dr. ir. H.M. (Michel) Bohms
Scientist Specialist
Structural Reliability

T +31 (0)88 866 31 07
M +31 (0)63 038 12 20
E michel.bo...@tno.nl<mailto:michel.bo...@tno.nl>

Location<http://www.tno.nl/locations/DTS>



<http://www.tno.nl/>
<image001.gif><http://www.tno.nl/>


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.




--
You received this message because you are subscribed to the Google Groups 
"TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
topbraid-users+unsubscr...@googlegroups.com<mailto:topbraid-users+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/topbraid-users/d10e05d774c245898d0d87645b27d977%40tno.nl<https://groups.google.com/d/msgid/topbraid-users/d10e05d774c245898d0d87645b27d977%40tno.nl?utm_medium=email&utm_source=footer>.
--
You received this message because you are subscribed to the Google Groups 
"TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
topbraid-users+unsubscr...@googlegroups.com<mailto:topbraid-users+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/topbraid-users/bb3e5ceb-0f66-6b4e-dfb3-11c64c3df869%40topquadrant.com<https://groups.google.com/d/msgid/topbraid-users/bb3e5ceb-0f66-6b4e-dfb3-11c64c3df869%40topquadrant.com?utm_medium=email&utm_source=footer>.
--
You received this message because you are subscribed to the Google Groups 
"TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
topbraid-users+unsubscr...@googlegroups.com<mailto:topbraid-users+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/topbraid-users/a888a69ee59b401581f2bfafbb6ae770%40tno.nl<https://groups.google.com/d/msgid/topbraid-users/a888a69ee59b401581f2bfafbb6ae770%40tno.nl?utm_medium=email&utm_source=footer>.
--
You received this message because you are subscribed to the Google Groups 
"TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
topbraid-users+unsubscr...@googlegroups.com<mailto:topbraid-users+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/topbraid-users/883E5E32-4ED1-4207-AF0A-D53CC3479E0D%40topquadrant.com<https://groups.google.com/d/msgid/topbraid-users/883E5E32-4ED1-4207-AF0A-D53CC3479E0D%40topquadrant.com?utm_medium=email&utm_source=footer>.

-- 
You received this message because you are subscribed to the Google Groups 
"TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to topbraid-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/topbraid-users/52b63b8d702c4b9c852f2c227fae1097%40tno.nl.

Reply via email to