You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by "Andy Seaborne (JIRA)" <ji...@apache.org> on 2014/05/19 15:41:39 UTC

[jira] [Closed] (JENA-697) Property Function to Split a String into Multiple Bindings

     [ https://issues.apache.org/jira/browse/JENA-697?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andy Seaborne closed JENA-697.
------------------------------


> Property Function to Split a String into Multiple Bindings
> ----------------------------------------------------------
>
>                 Key: JENA-697
>                 URL: https://issues.apache.org/jira/browse/JENA-697
>             Project: Apache Jena
>          Issue Type: New Feature
>            Reporter: Stephen Allen
>            Assignee: Stephen Allen
>            Priority: Minor
>
> It would be really useful to have a property function that could take a string, split it on some delineator and then return each token as a new binding.
> One example where it is useful is if you have some entities with keywords as concatenated literal strings.  It would be nice to extract them and perform some operation:
> {code}
> prefix : <http://example.org>
> prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
> insert data {
>   :a :keywords "report data important expensive" .
>   :b :keywords "data earthquake report" .
> }
> {code}
> Then query with:
> {code}
> prefix : <http://example.org>
> prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
> prefix apf: <http://jena.hpl.hp.com/ARQ/property#>
> select ?keyword (count(*) as ?c)
> where {
>   ?s :keywords ?text .
>   ?keyword apf:strSplit (?text " ")
> }
> group by ?keyword
> order by desc(?c) ?keyword
> {code}
> Results:
> {code}
> --------------------
> | keyword      | c |
> ====================
> | "data"       | 2 |
> | "report"     | 2 |
> | "earthquake" | 1 |
> | "expensive"  | 1 |
> | "important"  | 1 |
> --------------------
> {code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)