query-6ed0d327ab662511e94b10b5bb565e12

rq turtle/ttl

TODO

Use at

SELECT ?w (COUNT(*) AS ?c) WHERE {
  {
    VALUES (?title) {
      ("a test string to find a way to find the longest three (or so) substrings in a given string, though I would be fine with something like MAX(?substring) as well")
      ("being able to extract n-grams for n > 1 would be great too")
      (" another test string that starts and ends with space characters ")
      ("writing documentation is useful")
      ("more documentation can be even more useful")
      ("OneWordTitleInCamelCase")
      ("Thanks for your help!")
    }
  }
  BIND(REPLACE(?title, "^.*?(\\b\\w{3,}\\b).*$", "$1") AS ?w1)
  BIND(REPLACE(STRAFTER(?title, ?w1), "^.*?(\\b\\w{3,}\\b).*$", "$1") AS ?w2)
  BIND(REPLACE(STRAFTER(?title, ?w2), "^.*?(\\b\\w{3,}\\b).*$", "$1") AS ?w3)
#  FILTER(?w1 != ?w2 && ?w1 != ?w3 && ?w2 != ?w3)
  VALUES ?w_ { 1 2 3 }
  BIND(IF(?w_ = 1, ?w1, IF(?w_ = 2, ?w2, ?w3)) AS ?w)
#  FILTER(REGEX(?w, "^\\w+$")) # no idea why this is necessary
}
GROUP BY ?w
ORDER BY DESC(STRLEN(?w))

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v7("?c") v2("?title") v7("?w"):::projected v3("?w1") v4("?w2") v5("?w3") v6("?w_") bind0[/VALUES ?title/] bind0-->v2 bind00(["a test string to find a way to find the longest three (or so) substrings in a given string, though I would be fine with something like MAX(?substring) as well"]) bind00 --> bind0 bind01(["being able to extract n-grams for n > 1 would be great too"]) bind01 --> bind0 bind02([" another test string that starts and ends with space characters "]) bind02 --> bind0 bind03(["writing documentation is useful"]) bind03 --> bind0 bind04(["more documentation can be even more useful"]) bind04 --> bind0 bind05(["OneWordTitleInCamelCase"]) bind05 --> bind0 bind06(["Thanks for your help!"]) bind06 --> bind0 bind1[/"replace(?title,'^.*?(\b\w{3,}\b).*$','$1')"/] v2 --o bind1 bind1 --as--o v3 bind2[/"replace(substring-after(?title,?w1),'^.*?(\b\w{3,}\b).*$','$1')"/] v2 --o bind2 v3 --o bind2 bind2 --as--o v4 bind3[/"replace(substring-after(?title,?w2),'^.*?(\b\w{3,}\b).*$','$1')"/] v2 --o bind3 v4 --o bind3 bind3 --as--o v5 bind4[/VALUES ?w_/] bind4-->v6 bind40(["1^^xsd:integer"]) bind40 --> bind4 bind41(["2^^xsd:integer"]) bind41 --> bind4 bind42(["3^^xsd:integer"]) bind42 --> bind4 bind5[/"if(?w_ = '1^^xsd:integer',?w1,if(?w_ = '2^^xsd:integer',?w2,?w3))"/] v6 --o bind5 v3 --o bind5 v4 --o bind5 v5 --o bind5 bind5 --as--o v7 bind7[/"count(*)"/] bind7 --as--o v7