StringEditDistance

The EditDistance trait provides methods to compute and display the shortest distance between 2 strings.

Usage:

 showDistance("kitten", "sitting") // returns ("(k)itt(e)n", "(s)itt(i)n(g)")

// with different separators showDistance("kitten", "sitting", "[]") // returns ("[k]itt[e]n", "[s]itt[i]n[g]")
Companion:
object
class Object
trait Matchable
class Any
object StringEditDistance.type

Type members

Classlikes

case class StringDelimiter(separators: String)

Create delimiter characters

Create delimiter characters

Inherited classlikes

final case class Delimiter(value: String) extends Token
Inherited from:
DiffShortener
final case class End() extends Token
Inherited from:
DiffShortener
final case class Keep(value: String) extends Token
Inherited from:
DiffShortener
final case class Start() extends Token
Inherited from:
DiffShortener
sealed trait Token
Inherited from:
DiffShortener

Value members

Concrete methods

def editDistance(s1: String, s2: String): Int
def foldSplittedStrings[T](s1: String, s2: String, init: T, f: (T, String, String) => T): T

apply edit distance functions on strings split on newlines so that there are no memory issues

apply edit distance functions on strings split on newlines so that there are no memory issues

def showDiffs(operations: IndexedSeq[EditDistanceOperation[Char]], separators: String, shortenSize: Int): List[Token]
def showDistance(s1: String, s2: String, separators: String, shortenSize: Int): (String, String)
Value parameters:
separators

separators used to highlight differences. If sep is empty, then no delimiter is used. If sep contains one character, it is taken as the unique delimiter. If sep contains 2 or more characters, the first half of the characters are taken as opening delimiter and the second half as closing delimiter.

Returns:

a (String, String) displaying the differences between each input strings. The used separators are specified by the caller. The string is shortened before and after differences if necessary.

Inherited methods

def shorten(string: String, firstDelimiter: String, secondDelimiter: String, shortenSize: Int): String
Inherited from:
DiffShortener
def shortenTokens(tokens: List[Token], firstDelimiter: Delimiter, secondDelimiter: Delimiter, shortenSize: Int): List[Token]
Inherited from:
DiffShortener
def showToken(r: Token): String
Inherited from:
DiffShortener
def tokensSize(tokens: List[Token]): Int
Inherited from:
DiffShortener

Extensions

Inherited extensions

extension (tokens: List[Token])
def showTokens: String
Inherited from:
DiffShortener