Java – get the percentage of similarity between two texts

I need to score similarity between texts when one is inside the second

For example:

Text1: aaa bbb ccc ddd eee
Text2: bbb ccc

I need something to say that text2 is 100% in Text1 Is there a way to do this?

Solution

According to your needs, you can try

>The length of the longest common subsequence of two texts is divided by the length of text2 > or the length of the longest continuous subsequence of two texts is also divided by the length of text 2

If the text is completely within text1, both will be 1; If you do not share common characters, the two will be 0

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>