Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Natural Language Processing with Python Quick Start Guide

You're reading from   Natural Language Processing with Python Quick Start Guide Going from a Python developer to an effective Natural Language Processing Engineer

Arrow left icon
Product type Paperback
Published in Nov 2018
Publisher Packt
ISBN-13 9781789130386
Length 182 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Nirant Kasliwal Nirant Kasliwal
Author Profile Icon Nirant Kasliwal
Nirant Kasliwal
Arrow right icon
View More author details
Toc

Quick code means word vectors and heuristics

For the sake of simplicity, we will assume that our bot does not need to remember the context of any question. Therefore it sees input, responds to it, and is done. No links are established with the previous input.

Let's start by simply loading the word vectors using gensim:

import numpy as np
import gensim
print(f"Gensim version: {gensim.__version__}")

from tqdm import tqdm
class TqdmUpTo(tqdm):
def update_to(self, b=1, bsize=1, tsize=None):
if tsize is not None: self.total = tsize
self.update(b * bsize - self.n)

def get_data(url, filename):
"""
Download data if the filename does not exist already
Uses Tqdm to show download progress
"""
import os
from urllib.request import urlretrieve

if not os.path.exists(filename):

dirname = os.path.dirname(filename...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime