compare_documents function

Calculate the similarity of documents