String similarity score/hash

前端 未结 12 1231
长发绾君心
长发绾君心 2020-12-07 09:52

Is there a method to calculate something like general \"similarity score\" of a string? In a way that I am not comparing two strings together but rather I get some number (h

12条回答
  •  旧时难觅i
    2020-12-07 10:56

    Well, you could add up the ascii value of each character and then compare the scores, having a maximum value on which they can differ. This does not guarantee however that they will be similar, for the same reason two different strings can have the same hash value.

    You could of course make a more complex function, starting by checking the size of the strings, and then comparing each caracter one by one, again with a maximum difference set up.

提交回复
热议问题