in reply to calculate matching words/sentence

Try also Text::PhraseDistance that:

... provides a way to compare two phrases and to give a measure of their proximity.