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

Lyrics Quality is NaN and Inf #7

Open
wimbledon opened this issue Jul 29, 2021 · 2 comments
Open

Lyrics Quality is NaN and Inf #7

wimbledon opened this issue Jul 29, 2021 · 2 comments

Comments

@wimbledon
Copy link

Please reference #5 for more details.

@wimbledon
Copy link
Author

@ddddxxx

@wimbledon
Copy link
Author

The reason is that similarity func will return Inf if one of the input strings has zero length due to division by zero.

private func similarity(s1: String, s2: String) -> Double {
    let len = min(s1.count, s2.count)
    let diff = min(s1.distance(to: s2, insertionCost: 0), s1.distance(to: s2, deletionCost: 0))
    return Double(len - diff) / Double(len)
}

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

No branches or pull requests

1 participant