This section is included to assist the learners to perform the activities present in the book. It includes detailed steps that are to be performed by the learners to complete and achieve the objectives of the book.

Chapter 1: Introduction to Natural Language Processing

Activity 1: Generating word embeddings from a corpus using Word2Vec.


  1. Upload the text corpus from the link aforementioned.
  2. Import the word2vec from gensim models

    from gensim.models import word2vec

  3. Store the corpus in a variable.

    sentences = word2vec.Text8Corpus('text8')

  4. Fit the word2vec model on the corpus.

    model = word2vec.Word2Vec(sentences, size = 200)

  5. Find the most similar word to 'man'.


    The output is as follows: ...

Get Deep Learning for Natural Language Processing now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.