StringEditDistance

org.specs2.text.StringEditDistance
See theStringEditDistance companion object

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]")

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object StringEditDistance.type

Members list

Type members

Classlikes

case class StringDelimiter(separator: String)

Create separator characters

Create separator characters

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

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

Attributes

def showDiffs(operations: IndexedSeq[EditDistanceOperation[Char]], sep: String, shortenSize: Int): String
def showDistance(s1: String, s2: String, sep: String, shortenSize: Int): (String, String)

Value parameters

sep

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

Attributes

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(s: String, firstSep: String, secondSep: String, size: Int): String

Attributes

Inherited from:
DiffShortener