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

Add Levenshtein distance functions to string lib #3648

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

Beherith
Copy link
Collaborator

--- Calculates edit distance of two strings, O(n*m) time, O(n) memory
	---@param a string
	---@param b string
	---@return number 

	function string.Levenshtein(a,b)
	--- Finds string that is closest to a in a table
	---@param a string
	---@param t table, primarily values are strings, keys can be strings too
	---@return string, number bestresult, bestscore
	function string.FindClosest(a,t)

@Beherith Beherith requested a review from salinecitrine August 29, 2024 08:42
Copy link
Collaborator

@salinecitrine salinecitrine left a comment

Choose a reason for hiding this comment

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

What's the use case for this? Probably worth mentioning in the PR description.

common/stringFunctions.lua Outdated Show resolved Hide resolved
common/stringFunctions.lua Outdated Show resolved Hide resolved
common/stringFunctions.lua Outdated Show resolved Hide resolved
common/stringFunctions.lua Outdated Show resolved Hide resolved
common/stringFunctions.lua Outdated Show resolved Hide resolved
@WatchTheFort
Copy link
Member

@Beherith What is the status of this?

Beherith and others added 5 commits October 24, 2024 21:27
Co-authored-by: Citrine <salinecitrine@gmail.com>
Co-authored-by: Citrine <salinecitrine@gmail.com>
Co-authored-by: Citrine <salinecitrine@gmail.com>
Co-authored-by: Citrine <salinecitrine@gmail.com>
Co-authored-by: Citrine <salinecitrine@gmail.com>
common/stringFunctions.lua Outdated Show resolved Hide resolved
common/stringFunctions.lua Outdated Show resolved Hide resolved
Beherith and others added 2 commits November 3, 2024 10:16
Co-authored-by: Citrine <salinecitrine@gmail.com>
Co-authored-by: Citrine <salinecitrine@gmail.com>
@WatchTheFort
Copy link
Member

@Beherith Is this ready to merge?

1 similar comment
@WatchTheFort
Copy link
Member

@Beherith Is this ready to merge?

Copy link
Collaborator

@salinecitrine salinecitrine left a comment

Choose a reason for hiding this comment

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

tests pass

---@param a string
---@param t table, primarily values are strings, keys can be strings too
---@return string, number bestresult, bestscore
function string.FindClosest(a,t)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
function string.FindClosest(a,t)
function string.findClosestString(a,t)

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.

3 participants