Problem 848. Calculate a modified Levenshtein distance between two strings

Inspired by the Cody problem found here.
The Levenshtein distance is a charater-based string metric used to measure the difference between two strings (for details, look here). In this problem, you need to implement a word-based version of the Levenshtein distance.
Given two strings, compute the minimum number of word-edits to transform one string into another. The allowable edits are insertion, deletion, or substitution of a single word. Assume words are case-insensitive. Contractions and hyphenated words are allowed, but you may ignore other punctuation.
Example
If
s1 = 'I do not like MATLAB'
s2 = 'I love MATLAB a lot'
then
d = 4
because at least four edits are required to transform s1 into s2 (substitution on the last four words).

Solution Stats

23.15% Correct | 76.85% Incorrect
Last Solution submitted on Aug 21, 2024

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers120

Suggested Problems

More from this Author44

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!