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

include index in Rank #14

Merged
merged 1 commit into from
May 23, 2018
Merged

include index in Rank #14

merged 1 commit into from
May 23, 2018

Conversation

Evidlo
Copy link
Contributor

@Evidlo Evidlo commented May 20, 2018

This adds the string indices to the results returned from RankFind and RankFindFold.

This is especially useful when you want to sort non-string objects. You build an array containing the string representations of the objects, call RankFind on the array, and then use the indices returned to look up the original objects.

fuzzy/fuzzy.go Outdated
@@ -150,6 +156,9 @@ type Rank struct {

// Distance is the Levenshtein distance between Source and Target.
Distance int

// Location of Target in original list
Index int
Copy link
Owner

@lithammer lithammer May 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the naming could be a potential cause for confusion. I expect many to assume Index here means the index in the filtered list, not the original one. OriginalIndex maybe...? Naming is hard :)

Copy link
Owner

@lithammer lithammer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution!

@lithammer lithammer merged commit 500e0fc into lithammer:master May 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants