Chatbot: はじめてのチャットボット, Python, NLTK 4/4



Building a Simple Chatbot from Scratch in Python (using NLTK)


TF-IDF Approachまで学びました。


Chatbot:はじめてのチャットボットPython, NLTK 1/4

Chatbot:はじめてのチャットボット Python,NLTK 2/4

Chatbot:はじめてのチャットボット Python, NLTK 3/4


I.Cosine Similarity



2つのベクトルのDot Productをベクトルの長さの積で割ってCosine similarityを算出します。式は次です。


Cosine Similarity (d1, d2) = Dot product(d1, d2) / ||d1|| * ||d2||




Chatbot:Cosine Similarity, python


少しややこしいですが、文書を計算で選び出せるようにするのに、テキストをベクトルに変換し、ベクトル間の類似性をCosine Similariyで算出したと言えます。














About shibatau

I was born and grown up in Kyoto. I studied western philosophy at the University and specialized in analytic philosophy, especially Ludwig Wittgenstein at the postgraduate school. I'm interested in new technology, especially machine learning and have been learning R language for two years and began to learn Python last summer. Listening toParamore, Sia, Amazarashi and MIyuki Nakajima. Favorite movies I've recently seen: "FREEHELD". Favorite actors and actresses: Anthony Hopkins, Denzel Washington, Ellen Page, Meryl Streep, Mia Wasikowska and Robert DeNiro. Favorite books: Fyodor Mikhailovich Dostoyevsky, "The Karamazov Brothers", Shinran, "Lamentations of Divergences". Favorite phrase: Salvation by Faith. Twitter: @shibatau

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.