Bird
0
0

You want to compute the Levenshtein distance between two sentences by treating each word as a token. Which method correctly applies the Levenshtein distance in this context?

hard📝 Application Q8 of 15
NLP - Text Similarity and Search
You want to compute the Levenshtein distance between two sentences by treating each word as a token. Which method correctly applies the Levenshtein distance in this context?
ATokenize both sentences into word lists and compute Levenshtein distance treating each word as a single element
BCompute Levenshtein distance on the concatenated characters of both sentences without tokenization
CCalculate Levenshtein distance only on the first words of each sentence
DUse Levenshtein distance on the sentences after removing all spaces
Step-by-Step Solution
Solution:
  1. Step 1: Understand token-level Levenshtein

    To compare sentences word-by-word, tokenize into word lists.
  2. Step 2: Apply Levenshtein on tokens

    Compute distance treating each word as a token, not characters.
  3. Step 3: Analyze options

    Tokenize both sentences into word lists and compute Levenshtein distance treating each word as a single element correctly describes this approach. Others ignore tokenization or treat characters incorrectly.
  4. Final Answer:

    Option A -> Option A
  5. Quick Check:

    Tokenize sentences before applying Levenshtein for word-level distance. [OK]
Quick Trick: Tokenize sentences into words before distance calculation [OK]
Common Mistakes:
MISTAKES
  • Applying character-level distance directly on sentences
  • Ignoring tokenization step

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NLP Quizzes