Check if a text is present in a bigger text with an error tolerance

I need for the app I'm developping to create a function. This function will take three parameters :

  • A big text (let's call it the container text)
  • a smaller text (let's call it the contained text)
  • a tolerance

What I want this function to do is to check if the contained text is present in the container text, but it should say that it is true even if there is an error in the contained text.
For example, checking with this function if "This is an example" contains the subtext "an exumple" will still return true, even if the contained text isn't really present in the container text, because it is similar enought. The tolerance is just a way to decide if this is similar enought to be considered correct, I don't care about the way it is implanted.

Does anyone have an idea about how I could do that ?

This piece might be helpful:

If the contained text is a single word, split the big text at blanks to get a list of words, and calculate the minimum Levenshtein distance of that list of words against the contained text.

Compare the minimum Levenshtein distance against the tolerance.

If the contained text is not a single word, sweep the contained text against the big text letter by letter using the segment() block, seeking a minimum Levenshtein distance.


Thank you a lot ! That was exactly what I was looking for !

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.