
com.github.vickumar1981.stringdistance.impl.OverlapImpl.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of stringdistance_2.12 Show documentation
Show all versions of stringdistance_2.12 Show documentation
A fuzzy matching string distance library for Scala and Java.
The newest version!
package com.github.vickumar1981.stringdistance.impl
import com.github.vickumar1981.stringdistance.interfaces.NGramTokenizer
private[stringdistance] trait OverlapImpl extends NGramTokenizer {
protected def overlap[T](s1: Array[T], s2: Array[T], n: Int = 1): Double = {
require(n > 0, "Overlap score, ngram size must be a positive number.")
foldNGram(s1, s2, n)(0d)(_ => 1d) { (s1Tok, s2Tok, dist) =>
dist.toDouble / math.min(s1Tok.length, s2Tok.length)
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy