daft.functions.levenshtein_distance#
levenshtein_distance #
levenshtein_distance(left: Expression, right: Expression) -> Expression
Compute the Levenshtein edit distance between two strings.
The Levenshtein distance is the minimum number of single-character insertions, deletions, or substitutions required to transform one string into the other.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
left | Expression | The left string expression to compare. | required |
right | Expression | The right string expression to compare against. | required |
Returns:
| Type | Description |
|---|---|
Expression | The Levenshtein distance for each pair of strings. Returns null when either |
Expression | input is null. |
Examples:
1 2 3 4 5 | |
╭──────────┬─────────┬──────────╮
│ x ┆ y ┆ distance │
│ --- ┆ --- ┆ --- │
│ String ┆ String ┆ Int64 │
╞══════════╪═════════╪══════════╡
│ kitten ┆ sitting ┆ 3 │
├╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┤
│ saturday ┆ sunday ┆ 3 │
├╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┤
│ ┆ abc ┆ 3 │
╰──────────┴─────────┴──────────╯
(Showing first 3 of 3 rows) Source code in daft/functions/str.py
1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 | |