OK, I'm getting it now.  The value of a hasRestriction is a string, such as "( pm:fistName minCard 1) and" that needs to be parsed to get the constituent values.  I'd suggest you create SPIN functions that do this.  The function is created by defining a subclass of spin:Functions.  Let's say its named getNumOfRestrictions.  A constraint, let's use sp:arg1 is defined for  the function.  This will be the string to be parsed.  The body of the function will parse the string and get the number of restrictions value.  Using a regular _expression_ approach, the query body would look like:
  SELECT ?numRestrict
  WHERE
  {  LET (
?numRestrict := smf:regex("?arg1, ".* ([0-9]+ *)\\)$", "$1"))
  }

...where ?arg1 is defined as a spin:constraint for the function and the regex will find the last number, zero or more spaces and ')' in the string.  You could also use tops:split or the smf: string functions, such as smf:indexOf to parse the string.

Once the function is defined, it can be used in any SPARQL query.

For example
WHERE
{  ... 

    ?thing pmda:hasRestriction ?Restr .
    LET (?numRestr :=
getNumOfRestrictions(?Restr)) .
   ...
}
?thing pmda:hasRestriction ?Restr .

Similar functions can be used to get other values in the restriction.

For intersection and union, I'm still not quite clear, but you can parse the "and" or "or" and construct the logic.

-- Scott

On 3/3/11 10:47 PM, Guilherme Scomparim wrote:
Hi Scott,

  Sorry but I do not fully understand the question? pmda is just the
prefix of my own model.

  The reason I am trying to do this is because I am trying to infer an
executable model from metadata defined by Business Analysts.

   The idea is to capture the restrictions using a framework that
provides a screen with a grid where each line has drop downs fields
with Properties, Types of restrictions, values, “(“,  “)”, “and/or”,
with the possibility to include and delete lines in a simple way for
an end user, and then infer the triples using the SPIN:constructs like
this one I am trying to build.

   Then based on the fact that a particular pmda:State can have two or
more pmda:State:Restriction

I need to identify how many restrictions are for that state.
I need to test in case the first restriction has “(“ and doesn’t have
a “)” the next restriction until I find the “)”.
I also need to identify the ways they are linked ( “and/or”) to create
owl:intersectionOf and owl:unionOf between them

Here is an example with two restrictions

   pm:Consumer a pmda:State
 	hasRestriction “( pm:fistName minCard 1) and”
 	hasRestriction “(om:hasOrder minCard 1 ) “

This is the reason I need to learn how to use something like for each
in SPIN

Thanks again,
Guil

On Mar 4, 2:43 pm, Scott Henninger <[email protected]> wrote:
Does this have anything to do with OWL local restrictions?
Specifically, is your pmda: prefix defined as "http://www.w3.org/
2002/07/owl#"?

-- Scott

On Mar 3, 8:59 pm, Guilherme Scomparim <[email protected]> wrote:



Hi Scott,

        
  Sorry to confuse things. To make easier, forget about the
aggregation issue for now.

        
  Based on the triples that I sent before, I am already able to create
the construct below and it creates all the restrictions correctly.

        
CONSTRUCT {
    ?thing a owl:Class .
    ?thing rdfs:subClassOf owl:Thing .
    ?thing owl:equivalentClass _:b0 .
    _:b0 owl:onProperty ?OP .
    _:b0 owl:minCardinality ?Number .}

        
WHERE {
    ?thing a pmda:State .
    ?thing pmda:hasRestriction ?Restr .
    ?Restr pmda:restrictionOpenBracket ?OB .
    ?Restr pmda:restrictionCloseBracket ?CB .
    ?Restr pmda:restrictionNumber ?Number .
    ?Restr pmda:restrictionOnProperty ?OP .
    ?Restr pmda:restrictionSequence ?Seq .
    ?Restr pmda:restrictionType ?Typ .

        
}

        
My problem is that this construct cannot create the intersections and
unions required for some of these restrictions.

        
  In order to do that I need to understand how to use “For each” in
SPARQL to manipulate more than one record in the same construct like
pmda:restrictionOpenBracket[1] and pmda:restrictionCloseBracket[2]

        
 Any help in understanding better how to use For Each in SPARQL is
what I really need now.

        
  Thanks again,
Guil

        
On Mar 4, 12:59 pm, Scott Henninger <[email protected]>
wrote:

        
Hello Guil; I'm having a bit of trouble with the question.  The
initial paragraph talks about aggregates, but the rest seems to be a
non-standard representation of OWL restrictions.

        
In terms of "for each", the key is to understand how SPARQL works.
Given a graph pattern in the WHERE clause, a SPARQL engine will
produce a result for each match of the graph pattern.  In particular,
this means the "for each" is built into the SPARQL standard to start
with.

        
With that understanding, you may end up reformulating your approach,
so be sure to post any follow-on questions you may have.  BTW, the OWL
standard specifies a way of representing OWL restrictions.  So that's
also already available - see Help > How to? > Create a local
restriction, and look at the source code sub-tab.  Choose the Turtle
text serialization and you will see how OWL restrictions are
represented in RDF.

        
-- Scott

        
On Mar 3, 6:07 pm, Guilherme Scomparim <[email protected]> wrote:

        
Hi all,

        
I was wondering if there is a way to manipulate “recordsets” when
building a spin:construct

        
I am not sure if I am doing this in the proper way. Since I have not
found “For each” functionality in SPIN, I am trying to create
different queries using different filters that require count() and
group by to create different constructs based on the data in the
“recordsets” and this is not possible following the message “Aggregate
_expression_ not legal at this point”

        
To help understand my problem, I have a class called State that
relates to another class called StateRestriction via a particular
property. This relationship defines the restriction criterion for each
State as defined below.

        
    pmda:State a owl:Class .
    pmda:StateRestriction a owl:Class .
    pmda:hasRestriction rdfs:domain pmda:State .
    pmda:hasRestriction rdfs:range pmda:StateRestriction .
    pmda:restrictionSequence rdfs:domain pmda:StateRestriction .
    pmda:restrictionOpenBracket rdfs:domain pmda:StateRestriction .
    pmda:restrictionOnProperty rdfs:domain pmda:StateRestriction .
    pmda:restrictionType rdfs:domain pmda:StateRestriction .
    pmda:restrictionValue rdfs:domain pmda:StateRestriction .
    pmda:restrictionCloseBracket rdfs:domain pmda:StateRestriction .
    pmda:restrictionConjunctionDisjuntion rdfs:domain
pmda:StateRestriction .

        
I already create a construct that creates a restriction class for each
instance of the pmda:State.

        
Now I need to create the Intersections and Unions of the restrictions
that are defined as many instances of the pmda:StateRestriction for
each pmda:State.

        
This requires me to deal with a list of State Restrictions that are
related to a unique State and I am really not sure how to do that.

        
Thanks in Advance,
Guil- Hide quoted text -

        
- Show quoted text -- Hide quoted text -
- Show quoted text -

    

--
You received this message because you are subscribed to the Google
Group "TopBraid Suite Users", the topics of which include TopBraid Composer,
TopBraid Live, TopBraid Ensemble, SPARQLMotion and SPIN.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/topbraid-users?hl=en

Reply via email to