Classifying user intent

We want to be able to put sentences into categories by user intents. Intents are a generic mechanism that combine multiple individual examples into one semantic umbrella. For example, hi, hey, good morning, and wassup! are all examples of the _greeting_ intent.

Using greeting as an input, the backend logic can then determine how to respond to the user.

There are many ways we could combine word vectors to represent a sentence, but again we're going to do the simplest thing possible: add them up.

This is definitely a less-than-ideal solution, but works in practice because of the simple, unsupervised approach we use with this:

def sum_vecs(embed,text):    tokens = text.split(' ')    vec = np.zeros(embed.vector_size) for idx, ...

Get Natural Language Processing with Python Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.