Hi Jack,
On 9/04/2017 2:14, Jack Hodges wrote:
Thanks Irene. That is exactly what mine looks like, and it is indeed
very simple, and it returns nothing. But I figured this problem out.
The super class of the test had no instances but the subclasses did.
If I ran the function on the subclasses it worked fine, so I change
the wrapper to do ?cls refs:subClassOf* ?arg1 . and then ran the
counter on that, and then added a FILTER (?cls = ?arg1) . then I get
the right result.
Here is the modified wrapper:
*SELECT**
*WHERE*{
*BIND* (fonm:DimensionType *AS* ?arg1) .
?cls rdfs:subClassOf* ?arg1 .
*BIND* (behaviorspin:countEnumItems(?cls) *AS* ?cnt) .
*FILTER* (?cls = fonm:DimensionType) .
}
Thanks again. Now back to my list differences problem...
Jack
On Thursday, April 6, 2017 at 7:11:39 PM UTC-7, Irene Polikoff wrote:
Jack,
For your first question, this is what worked for me
On Apr 6, 2017, at 7:46 PM, Jack Hodges <[email protected]
<javascript:>> wrote:
I have 2 problems that I think might be related.
First, if I write a SPIN function countEnumItems to count the
number of items in an enumeration:
SELECTCOUNT(?known_dim)
WHERE{
?known_dima*?*dtype.
}
where ?dtype is an argument to the function, and I call this in a
SPARQL window, it works fine (answer for the test enumeration was
8). If I call like this:
SELECT ?cnt
WHERE {
BIND (fonm:DimensionType AS ?dtype) .
BIND (behaviorspin:countEnumItems(?dtype) AS ?cnt) .
}
I get some bizarrely huge number., like 20000. There are no
hidden subclasses on this type so the answer really is 8, so the
variable ?dtype is not getting bound. Why is that?
The second problem is that I have 2 'lists': a number of
dimensions defined as instances of an enumeration (there are 8,
as described above), and a number of dimensions associated with a
specific instance of connection (in my example, 4). I want to see
which dimensions in the full list are NOT members of the
connection 'list'. I wrote some magic properties to get me the 2
lists from instances, and then ran into a wall that there was no
way to do a simple list difference.
My next attempt was to write a function, dimMemberOf which takes
two arguments: a dimension, and a 'list' of dimensions, and
checks the given dimension against the 'list' of connection
dimensions. Of course, there was no such list of connection
dimensions and dimMemberOf was individually comparing the target
dimension against each of the connection dimensions. But this was
ok because I thought I could then count the number of trues and
falses for these comparisons. So I wrote some counting functions
and tested them, but when I called the counting functions as SPIN
functions instead of getting a count of the number of falses (3)
I got a count of 1 three times.
So I thought that since the SPIN function has an embedded magic
property in it perhaps that required that the SPIN function be
converted to a magic property as well. So I did that, but then I
got an error that I cannot count items in a magic property.
So I thought that I'd remove the COUNT and wrap the whole thing
into another SPIN function, but my SPIN function has 2 arguments
and I cannot use 2 arguments in a magic property (or can I?)
Magic properties *can* take multiple arguments (left hand side) and also
return multiple results (right hand side). The arguments must be called
sp:arg1, sh:arg2 etc.
Long and short of this question is that doing something that
would have cost me about 5 minutes in Java or some other language
is taking a long time in SPARQL.
FWIW 5.3 has greatly improved JavaScript support in case that is an
option to formulate your query logic.
Here is some sample code that works fine:
SELECT COUNT(?result)
WHERE {
BIND
(emech:SandTable_DW01Axle_M01Axle_FixedConnection-Restrain AS
?arg1) .
BIND (fonm:AlongLength AS ?dim) .
?arg1*behaviorswa:allRestrainRestrainedDimensions*?restDims .
BIND(behaviorspin:dimMemberOf(?dim,?restDims)*AS*?result) .
FILTER(?result=false) .}
The resulting value is 3. Here is the function call that doesn't
work:
SELECT ?cnt
WHERE{
BIND(emech:SandTable_DW01Axle_M01Axle_FixedConnection-Restrain*AS*?arg1)
.
BIND(fonm:AlongLength*AS*?dim) .
?arg1*behaviorswa:allRestrainRestrainedDimensions*?restDims.
BIND (behaviorspin:countMatchingDimInRestDims(?dim,
?restDims) AS ?cnt) .
}
It's a bit tricky for me to understand without more knowledge of the
data. But if the lower query returns multiple results then it means that
the magic property must return multiple results and it is looping over
these results (3 times?).
Holger
In this case I get 3 results (each with the value 1). The content
of the SPIN function is just the 2 lines in the first example,
and a COUNT(?result).
I do not understand either of these situations, and suspect that
the root is a basic misunderstanding of how SPIN is working. Any
clarification would be appreciated.
Jack
--
You received this message because you are subscribed to the
Google Group "TopBraid Suite Users", the topics of which include
the TopBraid Suite family of products and its base technologies
such as SPARQLMotion, SPARQL Web Pages and SPIN.
To post to this group, send email [email protected]
<javascript:>
---
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 [email protected] <javascript:>.
For more options, visithttps://groups.google.com/d/optout
<https://groups.google.com/d/optout>.
--
You received this message because you are subscribed to the Google
Group "TopBraid Suite Users", the topics of which include the TopBraid
Suite family of products and its base technologies such as
SPARQLMotion, SPARQL Web Pages and SPIN.
To post to this group, send email to [email protected]
---
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 [email protected]
<mailto:[email protected]>.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Group "TopBraid
Suite Users", the topics of which include the TopBraid Suite family of products and
its base technologies such as SPARQLMotion, SPARQL Web Pages and SPIN.
To post to this group, send email to [email protected]
---
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 [email protected].
For more options, visit https://groups.google.com/d/optout.