Edit distance: turning string differences into retroactive operations

Understanding dynamic planning and character-level evaluation by inserting, deleting and replacing.

Thematic shorts • IntroductionCollate in 1 diagram2 self-measured2 First-hand sources
Start Body
Learning objectives and first steps2 objectives 2 first fixes

Try to do it after reading

  • Understanding dynamic planning and character-level evaluation by inserting, deleting and replacing.
  • Check the input, label and evaluation conditions in the example

Suggested first

  • Text Tasks and Language Expressions
  • Conditional probability and vector calculations

How many steps between the two paragraphs

Levenshtein edits the minimum operating costs required to transform one sequence into another, usually allowing insertion, deletion and replacement. Serial units may be characters, words or other discrete symbols, with different units and different distances. It is appropriate for spelling error, text alignment and transliteration, but does not directly measure semantic approximation.

The word “cats” should be replaced by “dogs” only once, but the meaning may be different; Two sentences that express the same meaning may also require a lot of character manipulation. The editing distance is therefore a formal difference indicator that should be interpreted according to the mandate and cannot be used as a universal judgement of factual correctness or semantic equivalence.

Fill out prefix questions

Creates a table with lines that indicate source prefixes and columns that indicate target prefixes. The target for an empty string to reach j requires j to be inserted and the source-variable string for a i to be deleted i to be inserted. Each internal grid compares three sources: delete a source element, insert a target element, or match and replace the last pair of elements for a minimum cost.

For example, cat becomes cut, with the same initial end character, simply replaces a with u at a distance of 1. cat becomes cats requiring a single insertion and distance of 1. If the adjoining character exchange is considered to be an operation, it is another definition of distance that allows for conversion and cannot be secretly inserted into the thrust of a normal Levenshtein.

Backsliding is more useful than a number

When the distance is calculated, the return follows the optimal pre-refouler and can be modified in a specific way. Multiple paths may be equally optimal, indicating that the tool needs stable parallel rules. For long strings, the time and space of the complete table is usually the product of two lengths; Distance only allows for rolling rows, but restoring the complete path requires additional information or partition methods.

A common word error rate for voice-transliterations, with the number of words to be replaced, deleted and inserted divided by the number of references. If you insert a lot, the ratio can exceed 100% and does not mean that the formula is not working. The number of operations is affected by the division, labeling, case and numerical standardization, and the same agreement must be maintained.

The Unicode character also needs to be clearly compared with the particle size. A visible character may consist of multiple code points, which may be more varied if compared by bytes. Regularization, typographical and original deviations should be selected in conjunction with the scene. In addition to normal English, the tests should cover Chinese, accent characters and empty strings to avoid achieving only the simplest input correct.

Edit Distance Dynamic Planning TableEach grid is the minimum editorial distance between the two prefixes and the lower right corner 1 is the distance of the complete string.cat → cut: replace only a with u∅cut∅0123c1012a2112t3221The minimum cost of removing, inserting, matching/replacement of three sources for each cell.
Each grid is the minimum editorial distance between the two prefixes and the lower right corner 1 is the distance of the complete string.

Check understanding

Is there a semantic proximity between the two strings at one distance?

No, it's not. A single numeral, negation or physical substitution may change the core meaning. Edits the distance to describe only the cost of a change in form under the selected operation.

Why could the word error rate exceed 100%?

The denominator is the reference word, and the entry error is not limited by this number. When the system produces many redundant words, the total number of errors may be greater than the reference number.

Sources and reconciliations

Definitions, methods and interfaces are available.

  1. NLTK — edit distance
  2. Jurafsky and Martin — Words and Tokens

Figures and calculations are reorganized according to this chapter. Mathematical measurements, framework operations and real business effects are described separately in the body of the text.

← Back to the knowledge directory
Ask Max Ask about this site
Ask Max ↗

Opening the assistant…

Paper figure

Photo comments

LEAVE A NOTE

About this photograph

Connecting to the discussion board…

    Comments become public after moderation. You can delete your own comments from this browser.
    No email is required. Clearing cookies prevents this browser from claiming earlier comments.

    MAX WANG / INDEX

    Find something

    Enter a keyword, or explore the directory below.