Uploaded image for project: 'Apache Jena'
  1. Apache Jena
  2. JENA-697

Property Function to Split a String into Multiple Bindings

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • Jena 2.11.2
    • None
    • None

    Description

      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:

      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" .
      }
      

      Then query with:

      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
      

      Results:

      --------------------
      | keyword      | c |
      ====================
      | "data"       | 2 |
      | "report"     | 2 |
      | "earthquake" | 1 |
      | "expensive"  | 1 |
      | "important"  | 1 |
      --------------------
      

      Attachments

        Activity

          People

            sallen Stephen Allen
            sallen Stephen Allen
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: