Coder Social home page Coder Social logo

bigram-and-trigram-modeling's Introduction

Bigram-and-Trigram-Modeling

Find the code in Tag (Named Bigram)

Took the shared "Unigram Modeling.IPYNB" as the starting point for this task.

It builds a unigram language model.

And build the bigram and the trigram language models.

Took a corpus realdonaldtrump.csv. Take the tweets out. Remove any links and did the following:

1) Split data into 80% training and 20% test sets.
2) Remove punctuation marks.
3) Remove the newline characters.
4) Remove stopwords.
5) Use the n-grams module from nltk.util package to build bigrams and trigrams.
6) Find the frequencies of bigrams and trigrams in the corpus.
Tabulate them and show the histogram. Compare it with Zipf's Law.
7) Do Add-1 smoothing (Laplace) as explained in the slides.
8) Build a dictionary showing bigram and trigram probabilities against each sorted in increasing order.
9) Retabulate the reconstituted counts for the bigrams and the trigrams.
10) Redo the histogram and compare it again with Zipf's Law.
11) Take a four-word string as the test sample and find both its unigram, bigram, and trigram perplexities.
12) Natural Langauge Generation Task: Based on step 7, build CDF (Cumulative Distribution Function).
Generate a random number and compare it with the CDF.
Pick the word whose CDF value is closest to it and return it as the generated text.
13) Build the Shannon game as discussed in the class.
Predict the last word (hide it during prediction time) of the tweets in the test set based on one word before
(Bigram modeling), and two words before (trigram modeling), and evaluate the results using accuracy.

bigram-and-trigram-modeling's People

Contributors

kheem-dh avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.