Comparing Two Numeric Delta Strings

Does anyone know an easy way to compare two lines together to create a “quantity of difference” between the two? (in numerical value) I searched Google with little luck on this. And after some coding, it is not as easy as I thought. Any clues?

+4
source share
4 answers

Are you talking about "Change distance"? Do a search at Levenshtein distance, on SO or Google. I am using the version posted on Stephen Toub Blog

+5
source

You are looking for the Levenshtein distance .

+2
source

You might want to explore Levenshtein and Hamming . One calculates the editing distance (insert, delete, change), and the other bit flips.

+1
source

You will need to clearly define the “difference amount”. There is plenty of room for maneuver.

For example, the old C / C ++ strcmp() compares character by character and returns the difference the first time they do not match.

On the other hand, diff provides a complete list of the differences between two files (which in a sense are also strings). How would you rate this?

0
source

Source: https://habr.com/ru/post/1277622/


All Articles