Find most similar sentence in the file to the input sentence | NLP
In this article, we will find the most similar sentence in the file to the input sentence.
File content: "This is movie." "This is romantic movie" "This is a girl." Input: "This is a boy" Similar sentence to input: "This is a girl", "This is movie".
- Create a list to store all the unique words of the file.
- Convert all the sentences of the file into the binary format by comparing each word with the content of the list, after cleaning(removing stopword, stemming, etc.)
- Convert the input sentence in the binary format.
- Find the number of similar words in the input sentence to each sentence and store the value in the list named similarity index.
- Find the maximum value of similarity index and return the sentence having maximum similar words.
Content of the file:
Code to get a similar sentence:
My Personal Notes arrow_drop_up