How to check if two Strings are approximately equal?

前端 未结 6 2066
醉酒成梦
醉酒成梦 2021-02-04 05:30

I\'m making a chat responder for a game and i want know if there is a way you can compare two strings and see if they are approximatley equal to each other for example:

6条回答
  •  Happy的楠姐
    2021-02-04 06:04

    I believe you should use one of Edit distance algorithms to solve your problem. Here is for example Levenstein distance algorithm implementation in java. You may use it to compare words in the sentences and if sum of their edit distances would be less than for example 10% of sentence length consider them equals.

提交回复
热议问题