Member-only story
In our digital world, chatbots have become ubiquitous — we regularly encounter them on websites, messaging apps and customer support channels. With natural language capabilities powered by AI, today’s chatbots can understand diverse questions and handle increasingly complex conversations.
As one of AI’s most popular applications, chatbots are an engaging entry point for getting hands-on with Python’s extensive machine learning libraries. By combining a few key ingredients, we can cook up our own basic bot for a taste of this conversational future!
Understanding Natural Language with NLU
At the heart of any chatbot lies natural language understanding (NLU) — the ability to comprehend human languages. Python’s NLU ecosystem offers pre-built engines we can quickly integrate.
spaCy is a popular NLU library with pre-trained statistical models for multi-language text processing. After installing spaCy and loading its English model, we can parse sentences to extract key components:
import spacy
nlp = spacy.load('en_core_web_sm')
doc = nlp("Hello world, my name is Botty!")
for token in doc:
print(token.text, token.pos_, token.dep_)