I really did not know what to call it.
I have several tables structured this way
Offer table
id | sentence | ...
----------------------------
1 | See Spot run | ...
2 | See Jane run | ...
3 | Jane likes cheese | ...
Word table
id | word (unique)
----------
1 | See
2 | Spot
3 | run
4 | Jane
5 | likes
6 | cheese
And the table "word_references"
sentence_id | word_id
---------------------
1 | 1
1 | 2
1 | 3
2 | 1
2 | 3
2 | 4
3 | 4
3 | 5
3 | 6
I want to return a list of pairs of sentences that are similar to each other based on common words sorted by similarity. Therefore, he must return:
one | two | similarity
----------------------
1 | 2 | 2
2 | 3 | 1
because sentences 1 and 2 share two words: “Watch” and “run”, while sentences 2 and 3 use the same word: “Jane”.
source
share