Functions and magic properties
SPARQL Anything provides a number of magical functions and properties to facilitate the users in querying the sources and constructing knowledge graphs.
NOTE: SPARQL Anything is built on Apache Jena, see a list of supported functions on the Apache Jena documentation.
Name | Function/Magic Property | Input | Output | Description |
---|---|---|---|---|
fx:anySlot | Magic Property | - | - | This property matches the RDF container membership properties (e.g. rdf:_1 , rdf:_2 ...). |
fx:cardinal(?a) | Function | Container membership property | Integer | fx:cardinal(?a) returns the corresponding cardinal integer from ?a (rdf:_24 -> 24 ) |
fx:isContainerMembershipProperty(?p) | Function | Container membership property | Boolean | fx:isContainerMembershipProperty(?p) returns true if the node passed as parameter is a container membership property (rdf:_24 -> true ) |
fx:before(?a, ?b) | Function | Container membership properties | Boolean | fx:before(?a, ?b) returns true if ?a and ?b are container membership properties and ?a is lower than ?b , false otherwise |
fx:after(?a, ?b) | Function | Container membership property | Boolean | fx:after(?a, ?b) returns true if ?a and ?b are container membership properties and ?a is higher than ?b , false otherwise |
fx:previous(?a) | Function | Container membership property | Container membership property | fx:previous(?a) returns the container membership property that preceeds ?a (rdf:_2 -> rdf:_1 ) |
fx:next(?b) | Function | Container membership property | Container membership property | fx:next(?b) returns the container membership property that succeedes ?b (rdf:_1 -> rdf:_2 ) |
fx:forward(?a, ?b) | Function | Container membership property, Integer | Container membership property | fx:forward(?a, ?b) returns the container membership property that follows ?a of ?b steps (rdf:_2, 5 -> rdf:_7 ) |
fx:backward(?a, ?b) | Function | Container membership property, Integer | Container membership property | fx:backward(?a, ?b) returns the container membership property that preceeds ?a of ?b steps (rdf:_24, 4 -> rdf:_20 ) |
fx:String.startsWith(?stringA, ?stringB) | Function | String, String | Boolean | fx:String.startsWith wraps java.lang.String.startsWith |
fx:String.endsWith(?stringA, ?stringB) | Function | String, String | Boolean | fx:String.endsWith wraps java.lang.String.endsWith |
fx:String.indexOf(?stringA, ?stringB) | Function | String, String | Integer | fx:String.indexOf wraps java.lang.String.indexOf |
fx:String.lastIndexOf(?stringA, ?stringB) | Function | String, String | Integer | fx:String.lastIndexOf wraps java.lang.String.lastIndexOf |
fx:String.substring(?string) | Function | String, Integer, (Integer?) | String | fx:String.substring wraps java.lang.String.substring |
fx:String.toLowerCase(?string) | Function | String | String | fx:String.toLowerCase wraps java.lang.String.toLowerCase |
fx:String.toUpperCase(?string) | Function | String | String | fx:String.toUpperCase wraps java.lang.String.toUpperCase |
fx:String.replace(?string, ?characterA, ?characterB) | Function | String, Character, Character | String | fx:String.replace wraps java.lang.String.replace |
fx:String.trim(?string) | Function | String | String | fx:String.trim wraps java.lang.String.trim |
fx:String.stripLeading(?string) | Function | String | String | fx:String.stripLeading wraps java.lang.String.stripLeading |
fx:String.stripTrailing(?string) | Function | String | String | fx:String.stripTrailing wraps java.lang.String.stripTrailing |
fx:String.removeTags(?string) | Function | String | String | fx:String.removeTags removes the XML tags from the input string |
fxWordUtils.capitalize(?string) | Function | String | String | WordUtils.capitalize wraps org.apache.commons.text.WordUtils.capitalize |
fxWordUtils.capitalizeFully(?string) | Function | String | String | fx:WordUtils.capitalizeFully wraps org.apache.commons.text.WordUtils.capitalizeFully |
fx:WordUtils.initials(?string) | Function | String | String | fx:WordUtils.initials wraps org.apache.commons.text.WordUtils.initials |
fx:WordUtils.swapCase(?string) | Function | String | String | fx:WordUtils.swapCase wraps org.apache.commons.text.WordUtils.swapCase |
fx:WordUtils.uncapitalize(?string) | Function | String | String | fx:WordUtils.uncapitalize wraps org.apache.commons.text.WordUtils.uncapitalize |
fx:DigestUtils.md2Hex(?string) | Function | String | String | fx:DigestUtils.md2Hex wraps org.apache.commons.codec.digest.DigestUtils.md2Hex |
fx:DigestUtils.md5Hex(?string) | Function | String | String | fx:DigestUtils.md5Hex wraps org.apache.commons.codec.digest.DigestUtils.md5Hex |
fx:DigestUtils.sha1Hex(?string) | Function | String | String | fx:DigestUtils.sha1Hex wraps org.apache.commons.codec.digest.DigestUtils.sha1Hex |
fx:DigestUtils.sha256Hex(?string) | Function | String | String | fx:DigestUtils.sha256Hex wraps org.apache.commons.codec.digest.DigestUtils.sha256Hex |
fx:DigestUtils.sha384Hex(?string) | Function | String | String | fx:DigestUtils.sha384Hex wraps org.apache.commons.codec.digest.DigestUtils.sha384Hex |
fx:DigestUtils.sha512Hex(?string) | Function | String | String | fx:DigestUtils.sha512Hex wraps org.apache.commons.codec.digest.DigestUtils.sha512Hex |
fx:URLEncoder.encode(?string) | Function | String, String | String | fx:URLEncoder.encode wraps java.net.URLEncoder.encode |
fx:URLDecoder.decode(?string) | Function | String, String | String | fx:URLDecoder.decode wraps java.net.URLDecoder.decode |
fx:serial(?a ... ?n) | Function | Any sequence of nodes | Integer | The function fx:serial (?a ... ?n) generates an incremental number using the arguments as reference counters. For example, calling fx:serial("x") two times will generate 1 and then 2 . Instead, calling fx:serial(?x) multiple times will generate sequential numbers for each value of ?x . |
fx:entity(?a ... ?n) | Function | Any sequence of nodes | URI node | The function fx:entity (?a ... ?n) accepts a list of arguments and performs concatenation and automatic casting to string. Container membership properties (rdf:_1 ,rdf:_2 ,...) are cast to numbers and then to strings ("1","2" ). |
fx:literal(?a, ?b) | Function | String, (URI or language code) | Literal node | The function fx:literal( ?a , ?b ) builds a literal from the string representation of ?a , using ?b either as a typed literal (if a IRI is given) or a lang code (if a string of length of two is given). |
fx:bnode(?a) | Function | Any node | Blank node | The function fx:bnode( ?a) builds a blank node enforcing the node value as local identifier. This is useful when multiple construct templates are populated with bnode generated on different query solutions but we want them to be joined in the output RDF graph. Apparently, the standard function BNODE does generate a new node for each query solution (see issue #273 for an explanatory case). |
fx:LevenshteinDistance(?n1, ?n2) | Function | String, String | Integer | The function fx:LevenshteinDistance(?n1, ?n2) computes the Levenshtein Distance between ?n1 and ?n2 (see #182). |
fx:CosineDistance(?n1, ?n2) | Function | String, String | Double | The function fx:CosineDistance(?n1, ?n2) computes the Cosine Distance between ?n1 and ?n2 (see #182). |
fx:JaccardDistance(?n1, ?n2) | Function | String, String | Double | The function fx:JaccardDistance(?n1, ?n2) computes the Jaccard Distance between ?n1 and ?n2 (see #182). |
fx:JaroWinklerDistance(?n1, ?n2) | Function | String, String | Double | The function fx:JaroWinklerDistance(?n1, ?n2) computes the Jaro-Winkler Distance between ?n1 and ?n2 (see #182). |
fx:LongestCommonSubsequenceDistance(?n1, ?n2) | Function | String, String | Integer | The function fx:LongestCommonSubsequenceDistance(?n1, ?n2) computes the Longest Common Subsequence Distance between ?n1 and ?n2 (see #182). |
fx:HammingDistance(?n1, ?n2) | Function | String, String | Integer | The function fx:HammingDistance(?n1, ?n2) computes the Hamming Distance between ?n1 and ?n2 (see #182). |
fx:QGramDistance(?n1, ?n2) | Function | String, String | Double | The function fx:QGramDistance(?n1, ?n2) computes the QGram Distance between ?n1 and ?n2 (see #394). |
Working with sequences
fx:anySlot
The execution engine is sensible to the magic property fx:anySlot
.
This property matches the RDF container membership properties (e.g. rdf:_1
, rdf:_2
...).
Example
Query
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?slot
WHERE
{ SERVICE <x-sparql-anything:>
{ fx:properties
fx:content "[1,2,3]" ;
fx:media-type "application/json" .
?s fx:anySlot ?slot
}
}
Result
-----------------------------------------------
| slot |
===============================================
| "1"^^<http://www.w3.org/2001/XMLSchema#int> |
| "2"^^<http://www.w3.org/2001/XMLSchema#int> |
| "3"^^<http://www.w3.org/2001/XMLSchema#int> |
-----------------------------------------------
Functions on container membership properties
The system supports the following functions on container membership properties (See issue 78):
fx:cardinal
fx:cardinal(?a)
returns the corresponding cardinal integer from ?a
(rdf:_24
-> 24
)
Input
Container membership property
Output
Integer
Example
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?slot (fx:cardinal(?p) AS ?cardinal)
WHERE
{ SERVICE <x-sparql-anything:>
{ fx:properties
fx:content "[1,2,3]" ;
fx:media-type "application/json" .
?s ?p ?slot
FILTER ( ?p != rdf:type )
}
}
Result
----------------------------------------------------------
| slot | cardinal |
==========================================================
| "1"^^<http://www.w3.org/2001/XMLSchema#int> | 1 |
| "2"^^<http://www.w3.org/2001/XMLSchema#int> | 2 |
| "3"^^<http://www.w3.org/2001/XMLSchema#int> | 3 |
----------------------------------------------------------
fx:isContainerMembershipProperty
fx:isContainerMembershipProperty(?p)
returns true if the node passed as parameter is a container membership property (rdf:_24
-> true
)
Input
Container membership property
Output
Boolean
Example
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
SELECT ?resultTrue ?resultFalse
WHERE
{ BIND(fx:isContainerMembershipProperty(rdf:_42) AS ?resultTrue)
BIND(fx:isContainerMembershipProperty(42) AS ?resultFalse)
}
Result
----------------------------
| resultTrue | resultFalse |
============================
| true | false |
----------------------------
fx:before
fx:before(?a, ?b)
returns true
if ?a
and ?b
are container membership properties and ?a
is lower than ?b
, false
otherwise
Input
Container membership properties
Output
Boolean
Example
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT (fx:before(?p1, ?p2) AS ?p1_before_p2) (fx:before(?p2, ?p1) AS ?p2_before_p1) (fx:before(?p1, ?p1) AS ?p1_before_p1)
WHERE
{ SERVICE <x-sparql-anything:>
{ fx:properties
fx:content "[1,2,3]" ;
fx:media-type "application/json" .
?s ?p1 1 ;
?p2 2
}
}
Result
----------------------------------------------
| p1_before_p2 | p2_before_p1 | p1_before_p1 |
==============================================
| true | false | false |
----------------------------------------------
fx:after
fx:after(?a, ?b)
returns true
if ?a
and ?b
are container membership properties and ?a
is higher than ?b
, false
otherwise
Input
Container membership properties
Output
Boolean
Example
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT (fx:after(?p1, ?p2) AS ?p1_after_p2) (fx:after(?p2, ?p1) AS ?p2_after_p1) (fx:after(?p1, ?p1) AS ?p1_after_p1)
WHERE
{ SERVICE <x-sparql-anything:>
{ fx:properties
fx:content "[1,2,3]" ;
fx:media-type "application/json" .
?s ?p1 1 ;
?p2 2
}
}
Result
-------------------------------------------
| p1_after_p2 | p2_after_p1 | p1_after_p1 |
===========================================
| false | true | false |
-------------------------------------------
fx:previous
fx:previous(?a)
returns the container membership property that preceeds ?a
(rdf:_2
-> rdf:_1
)
Input
Container membership property
Output
Container membership property
Example
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?slot ?p (fx:previous(?p) AS ?previous)
WHERE
{ SERVICE <x-sparql-anything:>
{ fx:properties
fx:content "[1,2,3]" ;
fx:media-type "application/json" .
?s ?p ?slot
FILTER ( ?p != rdf:type )
}
}
Result
---------------------------------------------------------------------------------------------------------------------------------------------------
| slot | p | previous |
===================================================================================================================================================
| "1"^^<http://www.w3.org/2001/XMLSchema#int> | <http://www.w3.org/1999/02/22-rdf-syntax-ns#_1> | |
| "2"^^<http://www.w3.org/2001/XMLSchema#int> | <http://www.w3.org/1999/02/22-rdf-syntax-ns#_2> | <http://www.w3.org/1999/02/22-rdf-syntax-ns#_1> |
| "3"^^<http://www.w3.org/2001/XMLSchema#int> | <http://www.w3.org/1999/02/22-rdf-syntax-ns#_3> | <http://www.w3.org/1999/02/22-rdf-syntax-ns#_2> |
---------------------------------------------------------------------------------------------------------------------------------------------------
fx:next
fx:next(?b)
returns the container membership property that succeedes ?b
(rdf:_1
-> rdf:_2
)
Input
Container membership property
Output
Container membership property
Example
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?slot ?p (fx:next(?p) AS ?next)
WHERE
{ SERVICE <x-sparql-anything:>
{ fx:properties
fx:content "[1,2,3]" ;
fx:media-type "application/json" .
?s ?p ?slot
FILTER ( ?p != rdf:type )
}
}
Result
---------------------------------------------------------------------------------------------------------------------------------------------------
| slot | p | next |
===================================================================================================================================================
| "1"^^<http://www.w3.org/2001/XMLSchema#int> | <http://www.w3.org/1999/02/22-rdf-syntax-ns#_1> | <http://www.w3.org/1999/02/22-rdf-syntax-ns#_2> |
| "2"^^<http://www.w3.org/2001/XMLSchema#int> | <http://www.w3.org/1999/02/22-rdf-syntax-ns#_2> | <http://www.w3.org/1999/02/22-rdf-syntax-ns#_3> |
| "3"^^<http://www.w3.org/2001/XMLSchema#int> | <http://www.w3.org/1999/02/22-rdf-syntax-ns#_3> | <http://www.w3.org/1999/02/22-rdf-syntax-ns#_4> |
---------------------------------------------------------------------------------------------------------------------------------------------------
fx:forward
fx:forward(?a, ?b)
returns the container membership property that follows ?a
of ?b
steps (rdf:_2, 5
-> rdf:_7
)
Input
A container membership property and an integer
Output
Container membership property
Example
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?slot ?p (fx:forward(?p, 3) AS ?forward)
WHERE
{ SERVICE <x-sparql-anything:>
{ fx:properties
fx:content "[1,2,3]" ;
fx:media-type "application/json" .
?s ?p ?slot
FILTER ( ?p != rdf:type )
}
}
Result
---------------------------------------------------------------------------------------------------------------------------------------------------
| slot | p | forward |
===================================================================================================================================================
| "1"^^<http://www.w3.org/2001/XMLSchema#int> | <http://www.w3.org/1999/02/22-rdf-syntax-ns#_1> | <http://www.w3.org/1999/02/22-rdf-syntax-ns#_4> |
| "2"^^<http://www.w3.org/2001/XMLSchema#int> | <http://www.w3.org/1999/02/22-rdf-syntax-ns#_2> | <http://www.w3.org/1999/02/22-rdf-syntax-ns#_5> |
| "3"^^<http://www.w3.org/2001/XMLSchema#int> | <http://www.w3.org/1999/02/22-rdf-syntax-ns#_3> | <http://www.w3.org/1999/02/22-rdf-syntax-ns#_6> |
---------------------------------------------------------------------------------------------------------------------------------------------------
fx:backward
fx:backward(?a, ?b)
returns the container membership property that preceeds ?a
of ?b
steps (rdf:_24, 4
-> rdf:_20
)
Input
A container membership property and an integer
Output
Container membership property
Example
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?slot ?p (fx:backward(?p, 2) AS ?backward)
WHERE
{ SERVICE <x-sparql-anything:>
{ fx:properties
fx:content "[1,2,3]" ;
fx:media-type "application/json" .
?s ?p ?slot
FILTER ( ?p != rdf:type )
}
}
Result
---------------------------------------------------------------------------------------------------------------------------------------------------
| slot | p | backward |
===================================================================================================================================================
| "1"^^<http://www.w3.org/2001/XMLSchema#int> | <http://www.w3.org/1999/02/22-rdf-syntax-ns#_1> | |
| "2"^^<http://www.w3.org/2001/XMLSchema#int> | <http://www.w3.org/1999/02/22-rdf-syntax-ns#_2> | |
| "3"^^<http://www.w3.org/2001/XMLSchema#int> | <http://www.w3.org/1999/02/22-rdf-syntax-ns#_3> | <http://www.w3.org/1999/02/22-rdf-syntax-ns#_1> |
---------------------------------------------------------------------------------------------------------------------------------------------------
Working with strings
The system supports the following functions for string manipulation (See issue 104 and issue 121):
fx:String.startsWith
fx:String.startsWith
wraps java.lang.String.startsWith
Input
String
Output
Boolean
Example
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT (fx:String.startsWith(?string, "this") AS ?result1) (fx:String.startsWith(?string, "This") AS ?result2)
WHERE
{ SERVICE <x-sparql-anything:>
{ fx:properties
fx:content "this is a test" .
?s rdf:_1 ?string
}
}
Result
---------------------
| result1 | result2 |
=====================
| true | false |
---------------------
fx:String.endsWith
fx:String.endsWith
wraps java.lang.String.endsWith
Input
String, String
Output
Boolean
Example
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT (fx:String.endsWith(?string, "test") AS ?result1)
WHERE
{ SERVICE <x-sparql-anything:>
{ fx:properties
fx:content "this is a test" .
?s rdf:_1 ?string
}
}
Result
-----------
| result1 |
===========
| true |
-----------
fx:String.indexOf
fx:String.indexOf
wraps java.lang.String.indexOf
Input
String, String
Output
Integer
Example
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT (fx:String.indexOf(?string, "i") AS ?result1) (fx:String.indexOf(?string, "test") AS ?result2)
WHERE
{ SERVICE <x-sparql-anything:>
{ fx:properties
fx:content "this is a test" .
?s rdf:_1 ?string
}
}
Result
---------------------
| result1 | result2 |
=====================
| 2 | 10 |
---------------------
fx:String.lastIndexOf
fx:String.lastIndexOf
wraps java.lang.String.lastIndexOf
Input
String, String
Output
Integer
Example
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT (fx:String.lastIndexOf(?string, "b") AS ?result1)
WHERE
{ SERVICE <x-sparql-anything:>
{ fx:properties
fx:content "bob" .
?s rdf:_1 ?string
}
}
Result
-----------
| result1 |
===========
| 2 |
-----------
fx:String.substring
fx:String.substring
wraps java.lang.String.substring
Input
String, Integer, (Integer?)
Output
String
Example
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT (fx:String.substring(?string, 10) AS ?result1) (fx:String.substring(?string, 5, 7) AS ?result2)
WHERE
{ SERVICE <x-sparql-anything:>
{ fx:properties
fx:content "this is a test" .
?s rdf:_1 ?string
}
}
Result
---------------------
| result1 | result2 |
=====================
| "test" | "is" |
---------------------
fx:String.toLowerCase
fx:String.toLowerCase
wraps java.lang.String.toLowerCase
Input
String
Output
String
Example
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT (fx:String.toLowerCase(?string) AS ?result1)
WHERE
{ SERVICE <x-sparql-anything:>
{ fx:properties
fx:content "THIS IS A TEST" .
?s rdf:_1 ?string
}
}
Result
--------------------
| result1 |
====================
| "this is a test" |
--------------------
fx:String.toUpperCase
fx:String.toUpperCase
wraps java.lang.String.toUpperCase
Input
String
Output
String
Example
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT (fx:String.toUpperCase(?string) AS ?result1)
WHERE
{ SERVICE <x-sparql-anything:>
{ fx:properties
fx:content "this is a test" .
?s rdf:_1 ?string
}
}
Result
--------------------
| result1 |
====================
| "THIS IS A TEST" |
--------------------
fx:String.trim
fx:String.trim
wraps java.lang.String.trim
Input
String
Output
String
Example
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT (fx:String.trim(?string) AS ?result1)
WHERE
{ SERVICE <x-sparql-anything:>
{ fx:properties
fx:content " this is a test " .
?s rdf:_1 ?string
}
}
Result
--------------------
| result1 |
====================
| "this is a test" |
--------------------
fx:String.replace
fx:String.replace
wraps java.lang.String.replace
Input
String, Character, Character
Output
String
Example
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT (fx:String.replace(?string, "f", "d") AS ?result1)
WHERE
{ SERVICE <x-sparql-anything:>
{ fx:properties
fx:content "fog" .
?s rdf:_1 ?string
}
}
Result
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT (fx:String.replace(?string, "f", "d") AS ?result1)
WHERE
{ SERVICE <x-sparql-anything:>
{ fx:properties
fx:content "fog" .
?s rdf:_1 ?string
}
}
fx:String.stripLeading
fx:String.stripLeading
wraps java.lang.String.stripLeading
Input
String
Output
String
Example
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT (fx:String.stripLeading(?string) AS ?result1)
WHERE
{ SERVICE <x-sparql-anything:>
{ fx:properties
fx:content " this is a test " .
?s rdf:_1 ?string
}
}
Result
----------------------
| result1 |
======================
| "this is a test " |
----------------------
fx:String.stripTrailing
fx:String.stripTrailing
wraps java.lang.String.stripTrailing
Input
String
Output
String
Example
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT (fx:String.stripTrailing(?string) AS ?result1)
WHERE
{ SERVICE <x-sparql-anything:>
{ fx:properties
fx:content " this is a test " .
?s rdf:_1 ?string
}
}
Result
----------------------
| result1 |
======================
| " this is a test" |
----------------------
fx:String.removeTags
fx:String.removeTags
removes the XML tags from the input string
Input
String
Output
String
Example
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT (fx:String.removeTags(?string) AS ?result1)
WHERE
{ SERVICE <x-sparql-anything:>
{ fx:properties
fx:content "<p>This is a test</p>" .
?s rdf:_1 ?string
}
}
Result
--------------------
| result1 |
====================
| "This is a test" |
--------------------
Functions for manipulating words
The system supports the following functions to manipulate words (See issue 121).
fx:WordUtils.capitalize
fx:WordUtils.capitalize
wraps org.apache.commons.text.WordUtils.capitalize
Input
String
Output
String
Example
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT (fx:WordUtils.capitalize(?string) AS ?result1)
WHERE
{ SERVICE <x-sparql-anything:>
{ fx:properties
fx:content "This is a TEST" .
?s rdf:_1 ?string
}
}
Result
--------------------
| result1 |
====================
| "This Is A TEST" |
--------------------
fx:WordUtils.capitalizeFully
fx:WordUtils.capitalizeFully
wraps org.apache.commons.text.WordUtils.capitalizeFully
Input
String
Output
String
Example
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT (fx:WordUtils.capitalizeFully(?string) AS ?result1)
WHERE
{ SERVICE <x-sparql-anything:>
{ fx:properties
fx:content "This is a TEST" .
?s rdf:_1 ?string
}
}
Result
--------------------
| result1 |
====================
| "This Is A Test" |
--------------------
fx:WordUtils.initials
fx:WordUtils.initials
wraps org.apache.commons.text.WordUtils.initials
Input
String
Output
String
Example
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT (fx:WordUtils.initials(?string) AS ?result1)
WHERE
{ SERVICE <x-sparql-anything:>
{ fx:properties
fx:content "This is a TEST" .
?s rdf:_1 ?string
}
}
Result
-----------
| result1 |
===========
| "TiaT" |
-----------
fx:WordUtils.swapCase
fx:WordUtils.swapCase
wrapsorg.apache.commons.text.WordUtils.swapCase
Input
String
Output
String
Example
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT (fx:WordUtils.swapCase(?string) AS ?result1)
WHERE
{ SERVICE <x-sparql-anything:>
{ fx:properties
fx:content "This is a TEST" .
?s rdf:_1 ?string
}
}
Result
--------------------
| result1 |
====================
| "tHIS IS A test" |
--------------------
fx:WordUtils.uncapitalize
fx:WordUtils.uncapitalize
wraps org.apache.commons.text.WordUtils.uncapitalize
Input
String
Output
String
Example
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT (fx:WordUtils.uncapitalize(?string) AS ?result1)
WHERE
{ SERVICE <x-sparql-anything:>
{ fx:properties
fx:content "This is a TEST" .
?s rdf:_1 ?string
}
}
Result
--------------------
| result1 |
====================
| "this is a tEST" |
--------------------
Hash functions
The system supports the following functions for computing hash digest from strings (See issues 104 and 121):
fx:DigestUtils.md2Hex
fx:DigestUtils.md2Hex
wraps org.apache.commons.codec.digest.DigestUtils.md2Hex
Input
String
Output
String
Example
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT (fx:DigestUtils.md2Hex(?string) AS ?result1)
WHERE
{ SERVICE <x-sparql-anything:>
{ fx:properties
fx:content "This is a test" .
?s rdf:_1 ?string
}
}
Result
--------------------------------------
| result1 |
======================================
| "dc378580fd0722e56b82666a6994c718" |
--------------------------------------
fx:DigestUtils.md5Hex
fx:DigestUtils.md5Hex
wraps org.apache.commons.codec.digest.DigestUtils.md5Hex
Input
String
Output
String
Example
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT (fx:DigestUtils.md5Hex(?string) AS ?result1)
WHERE
{ SERVICE <x-sparql-anything:>
{ fx:properties
fx:content "This is a test" .
?s rdf:_1 ?string
}
}
Result
--------------------------------------
| result1 |
======================================
| "ce114e4501d2f4e2dcea3e17b546f339" |
--------------------------------------
fx:DigestUtils.sha1Hex
fx:DigestUtils.sha1Hex
wraps org.apache.commons.codec.digest.DigestUtils.sha1Hex
Input
String
Output
String
Example
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT (fx:DigestUtils.sha1Hex(?string) AS ?result1)
WHERE
{ SERVICE <x-sparql-anything:>
{ fx:properties
fx:content "This is a test" .
?s rdf:_1 ?string
}
}
Result
----------------------------------------------
| result1 |
==============================================
| "a54d88e06612d820bc3be72877c74f257b561b19" |
----------------------------------------------
fx:DigestUtils.sha256Hex
fx:DigestUtils.sha256Hex
wraps org.apache.commons.codec.digest.DigestUtils.sha256Hex
Input
String
Output
String
Example
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT (fx:DigestUtils.sha256Hex(?string) AS ?result1)
WHERE
{ SERVICE <x-sparql-anything:>
{ fx:properties
fx:content "This is a test" .
?s rdf:_1 ?string
}
}
Result
----------------------------------------------------------------------
| result1 |
======================================================================
| "c7be1ed902fb8dd4d48997c6452f5d7e509fbcdbe2808b16bcf4edce4c07d14e" |
----------------------------------------------------------------------
fx:DigestUtils.sha384Hex
fx:DigestUtils.sha384Hex
wraps org.apache.commons.codec.digest.DigestUtils.sha384Hex
Input
String
Output
String
Example
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT (fx:DigestUtils.sha384Hex(?string) AS ?result1)
WHERE
{ SERVICE <x-sparql-anything:>
{ fx:properties
fx:content "This is a test" .
?s rdf:_1 ?string
}
}
Result
------------------------------------------------------------------------------------------------------
| result1 |
======================================================================================================
| "a27c7667e58200d4c0688ea136968404a0da366b1a9fc19bb38a0c7a609a1eef2bcc82837f4f4d92031a66051494b38c" |
------------------------------------------------------------------------------------------------------
fx:DigestUtils.sha512Hex
fx:DigestUtils.sha512Hex
wraps org.apache.commons.codec.digest.DigestUtils.sha512Hex
Input
String
Output
String
Example
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT (fx:DigestUtils.sha512Hex(?string) AS ?result1)
WHERE
{ SERVICE <x-sparql-anything:>
{ fx:properties
fx:content "This is a test" .
?s rdf:_1 ?string
}
}
Result
--------------------------------------------------------------------------------------------------------------------------------------
| result1 |
======================================================================================================================================
| "a028d4f74b602ba45eb0a93c9a4677240dcf281a1a9322f183bd32f0bed82ec72de9c3957b2f4c9a1ccf7ed14f85d73498df38017e703d47ebb9f0b3bf116f69" |
--------------------------------------------------------------------------------------------------------------------------------------
Functions on URLs
The system supports the following functions operating on strings that are URLs (See issue 176):
fx:URLEncoder.encode
fx:URLEncoder.encode
wraps java.net.URLEncoder.encode
Input
- String to be translated.
- String - The name of a supported character encoding.
Output
String
Example
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT (fx:URLEncoder.encode(?string, "UTF-8") AS ?result1)
WHERE
{ SERVICE <x-sparql-anything:>
{ fx:properties
fx:content "/This is a test/" .
?s rdf:_1 ?string
}
}
Result
--------------------------
| result1 |
==========================
| "%2FThis+is+a+test%2F" |
--------------------------
fx:URLDecoder.decode
fx:URLEncoder.decode
wraps java.net.URLEncoder.decode
Input
String, The string to decode String, The name of a supported character encoding.
Output
Example
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT (fx:URLDecoder.decode(?string, "UTF-8") AS ?result1)
WHERE
{ SERVICE <x-sparql-anything:>
{ fx:properties
fx:content "This+is+a+test" .
?s rdf:_1 ?string
}
}
Result
--------------------
| result1 |
====================
| "This is a test" |
--------------------
Working with graph nodes
The system supports the following functions for working on the graph nodes.
fx:serial
The function fx:serial (?a ... ?n)
generates an incremental number using the arguments as reference counters. For example, calling fx:serial("x")
two times will generate 1
and then 2
. Instead, calling fx:serial(?x)
multiple times will generate sequential numbers for each value of ?x
.
Input
Any sequence of nodes
Output
Integer
Example
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?s (fx:serial(?s) AS ?serial)
WHERE
{ SERVICE <x-sparql-anything:>
{ fx:properties
fx:content "[1,2,1,2,4]" ;
fx:media-type "application/json" .
?c fx:anySlot ?s
}
}
Result
--------------------------------------------------------
| s | serial |
========================================================
| "1"^^<http://www.w3.org/2001/XMLSchema#int> | 1 |
| "2"^^<http://www.w3.org/2001/XMLSchema#int> | 1 |
| "1"^^<http://www.w3.org/2001/XMLSchema#int> | 2 |
| "2"^^<http://www.w3.org/2001/XMLSchema#int> | 2 |
| "4"^^<http://www.w3.org/2001/XMLSchema#int> | 1 |
--------------------------------------------------------
Example
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?wins ?team (fx:serial(?wins, ?team) AS ?serial)
WHERE
{ SERVICE <x-sparql-anything:>
{ fx:properties
fx:content "[{\"team\":\"Golden State Warriors\", \"year\":2015, \"wins\": 67}, {\"team\":\"Golden State Warriors\", \"year\":2016, \"wins\": 73}, {\"team\":\"Golden State Warriors\", \"year\":2017, \"wins\": 67}]" ;
fx:media-type "application/json" .
?c xyz:wins ?wins ;
xyz:team ?team
}
}
Result
Note: ?serial increments when a certain team concludes the season with a certain number of score.
-----------------------------------------------------------------------------------
| wins | team | serial |
===================================================================================
| "67"^^<http://www.w3.org/2001/XMLSchema#int> | "Golden State Warriors" | 1 |
| "73"^^<http://www.w3.org/2001/XMLSchema#int> | "Golden State Warriors" | 1 |
| "67"^^<http://www.w3.org/2001/XMLSchema#int> | "Golden State Warriors" | 2 |
-----------------------------------------------------------------------------------
fx:entity
The function fx:entity (?a ... ?n)
accepts a list of arguments and performs concatenation and automatic casting to string. Container membership properties (rdf:_1
,rdf:_2
,...) are cast to numbers and then to strings ("1","2"
).
BIND ( fx:entity ( myns:, "dummy-entity", 1) AS ?myentity)
# is equivalent to
BIND ( IRI( CONCAT ( STR (myns:), "dummy-entity", STR(1) ) AS ?myentity )
See also issue 106
Input
Any sequence of nodes
Output
URI Node
Example
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?team ?year (fx:entity("http://example.org/", fx:URLEncoder.encode(?team, "UTF-8"), ?year) AS ?entity)
WHERE
{ SERVICE <x-sparql-anything:>
{ fx:properties
fx:content "[{\"team\":\"Golden State Warriors\", \"year\":2015, \"wins\": 67}, {\"team\":\"Golden State Warriors\", \"year\":2016, \"wins\": 73}, {\"team\":\"Golden State Warriors\", \"year\":2017, \"wins\": 67}]" ;
fx:media-type "application/json" .
?c xyz:year ?year ;
xyz:team ?team
}
}
Result
-----------------------------------------------------------------------------------------------------------------------------
| team | year | entity |
=============================================================================================================================
| "Golden State Warriors" | "2015"^^<http://www.w3.org/2001/XMLSchema#int> | <http://example.org/Golden+State+Warriors2015> |
| "Golden State Warriors" | "2016"^^<http://www.w3.org/2001/XMLSchema#int> | <http://example.org/Golden+State+Warriors2016> |
| "Golden State Warriors" | "2017"^^<http://www.w3.org/2001/XMLSchema#int> | <http://example.org/Golden+State+Warriors2017> |
-----------------------------------------------------------------------------------------------------------------------------
fx:literal
The function fx:literal( ?a , ?b )
builds a literal from the string representation of ?a
, using ?b
either as a typed literal (if a IRI is given) or a lang code (if a string of length of two is given).
Input
String, (URI or language code)
Output
Literal node
Example
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT (fx:literal(?string, xsd:int) AS ?result)
WHERE
{ SERVICE <x-sparql-anything:>
{ fx:properties
fx:content "1" .
?s rdf:_1 ?string
}
}
Result
-----------------------------------------------
| result |
===============================================
| "1"^^<http://www.w3.org/2001/XMLSchema#int> |
-----------------------------------------------
Example
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT (fx:literal(?string, "it") AS ?result)
WHERE
{ SERVICE <x-sparql-anything:>
{ fx:properties
fx:content "uno" .
?s rdf:_1 ?string
}
}
Result
------------
| result |
============
| "uno"@it |
------------
fx:bnode
The function fx:bnode(?a)
builds a blank node enforcing the node value as local identifier. This is useful when multiple construct templates are populated with bnode generated on different query solutions but we want them to be joined in the output RDF graph. Apparently, the standard function BNODE
does generate a new node for each query solution (see issue #273 for an explanatory case).
Input
Any node
Output
Blank node
Example
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX ex: <http://example/>
CONSTRUCT
{
?bnode ex:p ?A .
}
WHERE
{ SERVICE <x-sparql-anything:>
{ fx:properties
fx:content "c1,c2\nb0,A\nb0,B\nb0,C\nb0,D\nb0,E\nb1,A\nb2,B\nb3,C\nb4,D\nb5,E" ;
fx:media-type "text/csv" ;
fx:csv.headers true .
_:b0 xyz:c1 ?b0 ;
xyz:c2 ?A
}
BIND(fx:bnode(?b0) AS ?bnode)
}
Note: the CSV passed as content string is the following
c1,c2
b0,A
b0,B
b0,C
b0,D
b0,E
b1,A
b2,B
b3,C
b4,D
b5,E
Result
@prefix ex: <http://example/> .
@prefix fx: <http://sparql.xyz/facade-x/ns/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix xyz: <http://sparql.xyz/facade-x/data/> .
[ ex:p "D" ] .
[ ex:p "A" ] .
[ ex:p "C" ] .
[ ex:p "E" ] .
[ ex:p "C" , "E" , "D" , "A" , "B" ] .
[ ex:p "B" ] .
fx:LevenshteinDistance
The function fx:LevenshteinDistance(?n1, ?n2)
computes the Levenshtein Distance between ?n1 and ?n2 (see #182).
Input
String, String
Output
Integer
Example
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
SELECT ?result WHERE {
BIND (fx:LevenshteinDistance("abc", "cbe") AS ?result)
}
Result
result |
---|
2 |
fx:CosineDistance
The function fx:CosineDistance(?n1, ?n2)
computes the Cosine Distance between ?n1 and ?n2 (see #182).
Input
String, String
Output
Double
Example
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
SELECT ?result WHERE {
BIND (fx:CosineDistance("abc", "cbe") AS ?result)
}
Result
result |
---|
1.0 |
fx:JaccardDistance
The function fx:JaccardDistance(?n1, ?n2)
computes the Jaccard Distance between ?n1 and ?n2 (see #182).
Input
String, String
Output
Double
Example
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
SELECT ?result WHERE {
BIND (fx:JaccardDistance("abc", "cbe") AS ?result)
}
Result
result |
---|
0.5 |
fx:JaroWinklerDistance
The function fx:JaroWinklerDistance(?n1, ?n2)
computes the Jaro-Winkler Distance between ?n1 and ?n2 (see #182).
Input
String, String
Output
Double
Example
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
SELECT ?result WHERE {
BIND (fx:JaroWinklerDistance("abc", "cbe") AS ?result)
}
Result
result |
---|
0.44444444444444453 |
fx:LongestCommonSubsequenceDistance
The function fx:LongestCommonSubsequenceDistance(?n1, ?n2)
computes the Longest Common Subsequence Distance between ?n1 and ?n2 (see #182).
Input
String, String
Output
Integer
Example
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
SELECT ?result WHERE {
BIND (fx:HammingDistance("abc", "abe") AS ?result)
}
Result
result |
---|
2 |
fx:HammingDistance
The function fx:HammingDistance(?n1, ?n2)
computes the Hamming Distance between ?n1 and ?n2 (see #182).
Input
String, String
Output
Integer
Example
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
SELECT ?result WHERE {
BIND (fx:HammingDistance("abc", "abe") AS ?result)
}
Result
result |
---|
1 |
fx:QGramDistance
The function fx:QGramDistance(?n1, ?n2)
computes the QGram Distance between ?n1 and ?n2 (see #394).
Input
String, String
Output
Double
Example
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
SELECT ?result WHERE {
BIND (fx:QGramDistance("abcd", "abce") AS ?result)
}
Result
result |
---|
2.0 |