Mark; I'm a bit unclear what you mean by " I would be interested in
knowing if there are alternatives to this approach that would have
worked if the value I was after was a literal". I think the core
concept is how URIs work - they uniquely define a resource - and that
literals work pretty much the same.
Given that, perhaps the following will help. RDF triples are facts.
If you re-assert the same fact, e.g. {<subj> <pred>
"xyz"^^xsd:string} multiple times, there is still just one fact -
{<subj> <pred> "xyz"^^xsd:string}. This is how your CONSTRUCT is
working as well. If the value of ?1 (the return value of
functions:GetTagPrefix(?name)) were the same, for example,
"fiddlestyx", your query would just create the same triple - {prod-
instance:fiddlestyx a prod:Instance}. This is a fact and there is
only one.
Let's modify your CONSTRUCT statement a bit:
CONSTRUCT
{ ?prefixUri a prod:Instrument .
?prefUri rdfs:label ?name .
}
If your data had these triples:
{ <some-x> <file:///Intuition%20Model/Imports/TalingaTagList.xls#nAME>
"name1"^^xsd:string .
<some-y> <file:///Intuition%20Model/Imports/TalingaTagList.xls#nAME>
"name1"^^xsd:string .
}
...your query would return the following triples:
{ prod-instance:name1 a prid:Instance .
prod-instance:name1 rdfs:label "name1"^^xsd:string .
}
Note that two triples align because the literal of the name is used to
create the instance.
If your data had these triples:
{ <some-x> <file:///Intuition%20Model/Imports/TalingaTagList.xls#nAME>
"name1"^^xsd:string .
<some-y> <file:///Intuition%20Model/Imports/TalingaTagList.xls#nAME>
"name2"^^xsd:string .
}
...your query would return the following triples:
{ prod-instance:name1 a prid:Instance .
prod-instance:name1 rdfs:label "name1"^^xsd:string .
prod-instance:name2 a prid:Instance .
prod-instance:name2 rdfs:label "name2"^^xsd:string .
}
I suspect you may have figured this out from your previous experiment,
but I wanted to establish this first. I'm not sure what you want from
literals, and perhaps a tweak of this example could help explain what
you mean.
-- Scott
On Oct 4, 1:25 am, Mark Colquhoun <[email protected]>
wrote:
> I did find a solution to this but I'm not sure if it is the best path
> forward? Because I need to construct a URI from the distinct value anyway,
> I used a ApplyConstruct module and constructed the new triples using the
> following query:
>
> *CONSTRUCT* {
>
> ?prefixUri a prod:Instrument .
>
> }
>
> *WHERE* {
>
> ?s <file:///Intuition%20Model/Imports/TalingaTagList.xls#nAME> ?name .
>
> *BIND* (smf:buildURI("prod-instance:{?1}", functions:GetTagPrefix(?name))
> *AS* ?prefixUri) .
>
> }
>
> Because I created a URI from the substring operation, only the unique URIs
> are returned by the Construct query. This seems to work well when dealing
> with URIs however I would be interested in knowing if there are
> alternatives to this approach that would have worked if the value I was
> after was a literal rather than a URI?
>
> Regards,
>
> Mark.
>
>
>
>
>
>
>
> On Thursday, October 4, 2012 3:03:17 PM UTC+10, Mark Colquhoun wrote:
>
> > Hi Irene,
>
> > Thanks for the detailed response. I did mention that I was reading from an
> > Excel spreadsheet but it was probably hidden deep in a previous post.
>
> > Based on the example I gave, I am reading data from a spreadsheet,
> > performing a substring operation on one of the columns. From there, I need
> > to identify the distinct values from this operation and create a new type
> > of thing by constructing new triples where the distinct value is used to
> > build the subject URI for the new triples.
>
> > I have been using SM for a while and now and have had reasonable success
> > however this problem has got me stumped probably because it requires me to
> > use a new feature that I haven't previously used.
>
> > Regards,
> > Mark.
>
> > On Thu, Oct 4, 2012 at 2:20 PM, Irene Polikoff <[email protected]>wrote:
>
> >> To add to Scott's reply, pretty much every SM module does one of the
> >> following:
>
> >> 1. Adds more triples into the pipeline (e.g., modules that import (load)
> >> RDF
> >> files or files that are auto-converted to RDF such as XML)
> >> 2. Establishes connection to external sources of triples (e.g., modules
> >> that
> >> connect to RDF databases, they are call "import" as well, but they just
> >> establish connection, they don't actually add triples from the external
> >> source into the pipeline)
> >> 3. Performs some processing based on triples that are passed to them as an
> >> input a) through the pipeline or b) from an external source (e.g, module
> >> that converts RDF to XML)
> >> 4. Does both 1 and 3 (e.g., inferencing modules or perform SPARQL update
> >> module)
> >> 5. Controls the processing (e.g., iterate over select)
> >> 6. Exports the results (e.g, all the "return" modules)
>
> >> Thus, a question to ask is what do you want to happen as a result of the
> >> select query? Depending on the answer, you may or may not need to run the
> >> select. Are you trying to return some RDF as a web service, for example?
> >> Then you don't really need the select query. Instead, you get to the point
> >> where the pipeline contains only the triples you want to return and the
> >> return module would return all of them.
>
> >> If you do need a select query and want to see modules that have it as a
> >> parameter, open your script, navigate to sml:selectQuery and see all the
> >> places it is referenced.
>
> >> Regards,
>
> >> Irene
>
> >> -----Original Message-----
> >> From: [email protected]
> >> [mailto:[email protected]] On Behalf Of Scott Henninger
> >> Sent: Wednesday, October 03, 2012 6:06 PM
> >> To: TopBraid Suite Users
> >> Subject: [topbraid-users] Re: SPARQLMotion Distinct
>
> >> Mark; Most SPARQLMotion modules include a query property. Some
> >> examples - that you can download - are found at
>
> >>http://www.topquadrant.com/products/SPARQLMotion_docs/SPARQLMotion_ex...
> >> aCapitals.html<http://www.topquadrant.com/products/SPARQLMotion_docs/SPARQLMotion_ex...>
> >> .
>
> >> I'd also suggest spending some time with the SPARQLMotion home page
> >> (http://www.topquadrant.com/products/SPARQLMotion.html) and the
> >> Getting Started Guide, Tutorial, and Videos provided on that page.
>
> >> Beyond that, if you have a more specific place you were looking to
> >> "use in a SPARQLMotion script to perform a SELECT query", let us
> >> know. A hint: IterateOverSelect is needed less often than one would
> >> initially believe because SPARQL's declarative nature take care of
> >> iteratively finding results.
>
> >> -- Scott
>
> >> On Oct 3, 3:02 pm, Mark Colquhoun <[email protected]>
> >> wrote:
> >> > Hi Scott,
>
> >> > Yes that will work but I guess I'm missing something as I couldn't see
> >> > which module I could use in a SPARQLMotion script to perform a SELECT
> >> query
> >> > apart from an Iterate Over Select?
>
> >> > Regards,
> >> > Mark.
>
> >> > On Thursday, October 4, 2012 12:11:28 AM UTC+10, Scott Henninger wrote:
>
> >> > > Will SELECT DISTINCT ?substr work? If not, we will need more
> >> > > information on what your queries and script look like, etc.
>
> >> > > -- Scott
>
> >> > > On Oct 2, 11:50 pm, Mark Colquhoun <[email protected]>
> >> > > wrote:
> >> > > > Hi,
>
> >> > > > Within a SPARQLMotion script, I need to read a spreadsheet and find
> >> the
> >> > > > distinct values in a column based on a substring performed on the
> >> > > column. I
> >> > > > can do all of this except the distinct part and am looking for some
> >> > > > pointers. An example of the data might be:
>
> >> > > > AI4120_0306_cH
> >> > > > AI4120_0306_cHH
> >> > > > AIC4120_0042_cSP
> >> > > > AIC4120_0042_sCV
>
> >> > > > From these values, I want to create a substring including everything
> >> to
> >> > > the
> >> > > > left of the last _.
>
> >> > > > AI4120_0306
> >> > > > AI4120_0306
> >> > > > AIC4120_0042
> >> > > > AIC4120_0042
>
> >> > > > Easy enough so far but from here I want to select the distinct
> >> values.
> >> > > I'm
> >> > > > sure this should be easy but I haven't been able to find any build
> >> in
> >> > > > functionality to achieve this. The end result that am after should
> >> look
> >> > > > like:
>
> >> > > > AI4120_0306
> >> > > > AIC4120_0042
>
> >> > > > I'm sure there is something that I am overlooking so any help would
> >> be
> >> > > > greatly appreciated.
>
> >> > > > Regards,
> >> > > > Mark.
>
> >> --
> >> -- You received this message because you are subscribed to the Google
> >> Group "TopBraid Suite Users", the topics of which include Enterprise
> >> Vocabulary Network (EVN), TopBraid Composer, TopBraid Live,
> >> TopBraid Ensemble, SPARQLMotion, SPARQL Web Pages 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
>
> >> --
> >> -- You received this message because you are subscribed to the Google
> >> Group "TopBraid Suite Users", the topics of which include Enterprise
> >> Vocabulary Network (EVN), TopBraid Composer, TopBraid Live,
> >> TopBraid Ensemble, SPARQLMotion, SPARQL Web Pages 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
--
-- You received this message because you are subscribed to the Google
Group "TopBraid Suite Users", the topics of which include Enterprise Vocabulary
Network (EVN), TopBraid Composer, TopBraid Live,
TopBraid Ensemble, SPARQLMotion, SPARQL Web Pages 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