-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added similarity score and retified some object update issues a…
…cross phases Signed-off-by: AlexsJones <[email protected]>
- Loading branch information
1 parent
f4983cb
commit 002a6cb
Showing
7 changed files
with
149 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package util | ||
|
||
import "github.com/agnivade/levenshtein" | ||
|
||
func SimilarityScore(text1 string, text2 string) float64 { | ||
// Calculate the Levenshtein distance. | ||
distance := levenshtein.ComputeDistance(text1, text2) | ||
|
||
// Calculate the maximum length between the two strings. | ||
maxLength := max(len(text1), len(text2)) | ||
|
||
// Calculate the similarity score as a percentage. | ||
similarity := (1.0 - float64(distance)/float64(maxLength)) * 100.0 | ||
|
||
return similarity | ||
} | ||
|
||
// max returns the maximum of two integers. | ||
func max(a, b int) int { | ||
if a > b { | ||
return a | ||
} | ||
return b | ||
} |