You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by emri mbiemri <em...@gmail.com> on 2021/03/27 13:33:56 UTC

Using Levenstein distance within SPARQL

Hi,

I am interested to know if there is any way I could use Levenstein distance within a SPARQL query. Let's say I want to select only the objects that have a Levenstein distance < 3. I have seen a function on a side that says LEVENSHTEIN_DIST(string1, string2) is supported by SPARQL, but it is not working for me.
I appreciate your help.  

Re: Using Levenstein distance within SPARQL

Posted by Andy Seaborne <an...@apache.org>.

On 29/03/2021 07:32, Lorenz Buehmann wrote:
> that's non-standard SPARQL. You have to add a custom function in that 
> case, for a local Apache Jena triple store it works like described here 
> [1]. When querying other remote endpoint of course is does not and you 
> have to check for support on their underlying triple store.
> 
> 
> [1] https://jena.apache.org/documentation/query/extension.html

There is an implementation of the alogorithm in Apache Commons Text, 
along with other measures:

https://commons.apache.org/proper/commons-text/javadocs/api-release/org/apache/commons/text/similarity/package-summary.html

     Andy

> 
> On 27.03.21 14:33, emri mbiemri wrote:
>> Hi,
>>
>> I am interested to know if there is any way I could use Levenstein 
>> distance within a SPARQL query. Let's say I want to select only the 
>> objects that have a Levenstein distance < 3. I have seen a function on 
>> a side that says LEVENSHTEIN_DIST(string1, string2) is supported by 
>> SPARQL, but it is not working for me.
>> I appreciate your help.

Re: Using Levenstein distance within SPARQL

Posted by Lorenz Buehmann <bu...@informatik.uni-leipzig.de>.
that's non-standard SPARQL. You have to add a custom function in that 
case, for a local Apache Jena triple store it works like described here 
[1]. When querying other remote endpoint of course is does not and you 
have to check for support on their underlying triple store.


[1] https://jena.apache.org/documentation/query/extension.html

On 27.03.21 14:33, emri mbiemri wrote:
> Hi,
>
> I am interested to know if there is any way I could use Levenstein distance within a SPARQL query. Let's say I want to select only the objects that have a Levenstein distance < 3. I have seen a function on a side that says LEVENSHTEIN_DIST(string1, string2) is supported by SPARQL, but it is not working for me.
> I appreciate your help.

Re: Using Levenstein distance within SPARQL

Posted by Chris Wood <c....@gmail.com>.
Hi Emri,

I'd guess you've seen the function in the AnzoGraph documentation:
https://docs.cambridgesemantics.com/anzograph/v2.3/userdoc/string-functions.htm?
CambridgeSemantics have developed an extended set of functions beyond those
in the SPARQL 1.1 specification:
https://www.w3.org/TR/2013/REC-sparql11-query-20130321/

If you're not using AnzoGraph, I'd guess you'd need to implement the
function yourself.

Chris

On Sat, 27 Mar 2021 at 13:34, emri mbiemri <em...@gmail.com>
wrote:

> Hi,
>
> I am interested to know if there is any way I could use Levenstein
> distance within a SPARQL query. Let's say I want to select only the objects
> that have a Levenstein distance < 3. I have seen a function on a side that
> says LEVENSHTEIN_DIST(string1, string2) is supported by SPARQL, but it is
> not working for me.
> I appreciate your help.
>