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:
SELECT COUNT(?known_dim)
WHERE {
?known_dim a *?*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?)
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.
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)
.
}
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 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.