Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: levenstein distance for duplicated letters #2849

Merged
merged 2 commits into from Oct 27, 2021
Merged

fix: levenstein distance for duplicated letters #2849

merged 2 commits into from Oct 27, 2021

Commits on Oct 8, 2021

  1. fix: levenstein distance for duplicated letters

    Fix a bug where a duplicated letter was not contributing to the
    distance, if transposition was set to true and duplicated letter was the
    left argument.
    
    ```python3
    edit_distance("duuplicated", "duplicated", transpositions=False)
    edit_distance("duplicated", "duuplicated", transpositions=True)
    edit_distance("duuplicated", "duplicated", transpositions=True)
    # all return 1 - correct
    
    edit_distance("duplicated", "duuplicated", transpositions=True)
    # returns 0 - incorrect
    ```
    
    I believe it is a bug introduced three weeks ago by PR [2736].
    
    The fix make nltk implementation closer to the [wikipedia] pseudo code,
    which should make further reviews / iteration easier I believe.
    
    [2736]: #2736
    [wikipedia]: https://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance#Distance_with_adjacent_transpositions
    p9f committed Oct 8, 2021
    Configuration menu
    Copy the full SHA
    ab53eb8 View commit details
    Browse the repository at this point in the history

Commits on Oct 12, 2021

  1. refactor: make edit distance closer to wikipedia pseudo code

    Start i / j loops from 1 and not 0 to make the code closer to
    [wikipedia] pseudo code, as requested by this pull request comment [0].
    
    [wikipedia]: https://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance#Distance_with_adjacent_transpositions
    [0]: #2849 (comment)
    p9f committed Oct 12, 2021
    Configuration menu
    Copy the full SHA
    de73ed2 View commit details
    Browse the repository at this point in the history