[ 
https://issues.apache.org/jira/browse/TEXT-191?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17317852#comment-17317852
 ] 

Bradley Rumball commented on TEXT-191:
--------------------------------------

Hi [~kinow]

No worries at all, I came here due to using this function on a project and 
finding that the distance was driving one of the fitness functions I was 
working on in the wrong direction; I think it's safe to say it's a bug that 
needed squashing!

Thanks for updating the PR to using 1-similarity for the distance; this is far 
superior; I wanted to do this but wasn't sure if it was previously implemented 
like this to reduce stack depth; in short, I'm very much in favour of what 
you've done.

In the future, it would be great to see the package of "similarity" classes 
provided as final utility classes; it's unnatural to have to create instances 
for them.
I'd happily work on this and provide a PR for in a future version; it would be 
great to hear everyone's thoughts!

Aside from this, I'm happy for the merge to go ahead!

Best wishes,

Bradley

> JaroWinklerDistance returns the same values as JaroWinklerSimilarity
> --------------------------------------------------------------------
>
>                 Key: TEXT-191
>                 URL: https://issues.apache.org/jira/browse/TEXT-191
>             Project: Commons Text
>          Issue Type: Bug
>    Affects Versions: 1.9
>         Environment: Windows 10
> AdoptOpenJDK 11
>            Reporter: Alexander Foerster
>            Assignee: Bruno P. Kinoshita
>            Priority: Major
>              Labels: JaroWinkler, easyfix, newbie
>             Fix For: 1.10
>
>
>  
> The following two code snippets give the same output:
> {code:java}
> // checking similarity
> JaroWinklerSimilarity jws = new JaroWinklerSimilarity();
> System.out.println("SIMILARITY: " + jws.apply("foo", "foo") + "  " + 
> jws.apply("foo", "bar"));
> // SIMILARITY: 1.0  0.0{code}
> {code:java}
> // checking distance
> JaroWinklerDistance jwd = new JaroWinklerDistance();
> System.out.println("DISTANCE: " + jwd.apply("foo", "foo") + "  " + 
> jwd.apply("foo", "bar"));
> // DISTANCE: 1.0  0.0
> {code}
> I would expect the distance to be 1 - similarity, but as you can see distance 
> and similarity return the same values.
>  
> An easy fix would be to use the commented lines in JaroWinklerDistance.java:
> {code:java}
> // JaroWinklerSimilarity similarity = new JaroWinklerSimilarity();
> // return 1 - similarity.apply(left, right);
> {code}
> and maybe make _similarity_ be a final property/variable.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to