Uploaded image for project: 'Commons Text'
  1. Commons Text
  2. TEXT-191

JaroWinklerDistance returns the same values as JaroWinklerSimilarity

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.9
    • 1.10.0
    • Windows 10
      AdoptOpenJDK 11

    Description

       

      The following two code snippets give the same output:

      // checking similarity
      JaroWinklerSimilarity jws = new JaroWinklerSimilarity();
      System.out.println("SIMILARITY: " + jws.apply("foo", "foo") + "  " + jws.apply("foo", "bar"));
      // SIMILARITY: 1.0  0.0
      // checking distance
      JaroWinklerDistance jwd = new JaroWinklerDistance();
      System.out.println("DISTANCE: " + jwd.apply("foo", "foo") + "  " + jwd.apply("foo", "bar"));
      // DISTANCE: 1.0  0.0
      

      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:

      // JaroWinklerSimilarity similarity = new JaroWinklerSimilarity();
      // return 1 - similarity.apply(left, right);
      

      and maybe make similarity be a final property/variable.

      Attachments

        Issue Links

          Activity

            People

              kinow Bruno P. Kinoshita
              Govery76 Alexander Foerster
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 0.5h
                  0.5h