Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 528213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:57:49+00:00 2026-05-13T08:57:49+00:00

I’m creating a web app in PHP where people can try to translate words

  • 0

I’m creating a web app in PHP where people can try to translate words they need to learn for school.

For example, someone needs to translate the Dutch word ‘weer’ to ‘weather’ in English, but unfortunately he types ‘whether’. Because he almost typed the right word, I want to give him another try, with dots ‘.‘ on the places where he made a mistake:

Language A:   weer
Language B:   weather
Input:        whether
Output:       w..ther

Or, for example

Language A:   fout
Language B:   mistake
Input:        mitake
Output:       mi.take

Or:

Language A:   echt
Language B:   genuine
Input:        genuinely
Output:       genuinely (almost good, shorten the word a little bit)

But, if the input differs too much from the desired translation, I don’t want to get output like ........

I heard about Levenshtein distance and I think I need an algorithm that is much like that one, but I don’t know how to place dots on the right place instead of echoing how many operations are to be done.

So, how can I return the misspelled word with dots on the places where someone made a mistake?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T08:57:50+00:00Added an answer on May 13, 2026 at 8:57 am

    First, take a look at the Levenshtein algorithm on wikipedia.
    Then go on and look at the examples and the resulting matrix d on the article page:

                    *k*     *i*     *t*     *t*     *e*     *n*
            >0       1       2       3       4       5       6 
    *s*      1      >1       2       3       4       5       6 
    *i*      2       2      >1       2       3       4       5 
    *t*      3       3       2      >1       2       3       4 
    *t*      4       4       3       2      >1       2       3 
    *i*      5       5       4       3       2      >2       3 
    *n*      6       6       5       4       3       3      >2 
    *g*      7       7       6       5       4       4      >3 
    

    The distance is found on lower right corner of the matrix, d[m, n]. But from there it
    is now possible to follow backtrack the minimum steps to the upper left of of the matrix, d[1, 1]. You just go left, up-left, or up at each step whichever minimizes the path.
    In the example above, you’d find the path marked by the ‘>’ signs:

      s i t t i n g      k i t t e n
    0 1 1 1 1 2 2 3    0 1 1 1 1 2 2 3
      ^       ^   ^      ^       ^   ^
      changes in the distance, replace by dots
    

    Now you can find on the minimum path at which locations d[i,j] the distance changes (marked by ^ in the example above), and for those letters you put in the first (or second) word a dot at position i (or j respectively).

    Result:

      s i t t i n g      k i t t e n
      ^       ^   ^      ^       ^   ^
      . i t t . n .      . i t t . n . 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I am trying to loop through a bunch of documents I have to put
I'm making a simple page using Google Maps API 3. My first. One marker
I have some data like this: 1 2 3 4 5 9 2 6

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.