def describe_word(bot, update, word): st = Stats() c = st.get_counter(st, update.message.chat_id) vs = Visual() image1 = vs.word_rank(vs, c, word) bot.send_photo(update.message.chat_id, photo=image1) text = 'Most common words after {}\n'.format(word) words_n = st.words_near(st, update.message.chat_id, word) for i, item in enumerate(words_n): a, b = item text += '{}. {} {}\n'.format(i, a, b) update.message.reply_text(text) d = st.dist_by_sentence(st, update.message.chat_id, word) image2 = vs.dist_by_sentence(vs, d, word) bot.send_photo(update.message.chat_id, photo=image2)