-2

For example, when String A has a total of 10 words and String B has total of 100 words, all words in String A are found in String B the result would be a 100% match. If half are found, it is a 50% match. What algorithm produces results like this?

3

1 Answer 1

0

I will try to write a PHP like code

wordsA = explode(' ', A);
wordsB = explode(' ', B);
match = 0;
foreach (wordsA as word) {
    if (in_array(word, wordsB)) {
        match++;
    }
}
echo (count(wordsB)/match*100.'%');
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.