Giter VIP home page Giter VIP logo

languagemodelling-and-tokenization's Introduction

tokenizer.py

Tokenizer.py is a Python module that provides a customizable tokenizer class. The class allows you to tokenize sentences and words in a given text. Additionally, it includes functionality to identify and replace occurrences of Numbers, Mail IDs, Punctuation, URLs, Hashtags (#nlp), and Mentions (@sailesh).

Features

  • Tokenize sentences and words in a given text.
  • Identify and replace the following occurrences:
    • Numbers replaced with <NUM>.
    • Mail IDs replaced with <MAILID>.
    • Punctuation identified.
    • URLs replaced with <URL>.
    • Hashtags (#nlp) replaced with <HASHTAG>.
    • Mentions (@sailesh) replaced with <MENTION>.

n_gram.py

ngram.py is a Python module that provides a function which takes in the parameters - tokenized words of a text and n (in n-gram).

  • Calculate the count of occurrences of a word given a history.
  • It also tracks the total number of occurrences of all word for that history in the "TotalCnt" i.e final_prob[history]["TotalCnt"] gives the total occurences of that history . This is used for calulating the probability.

language_model.py

  • Implemented Good turing smoothing.
    • For training this on 1.txt - python3 language_model.py g ./corpus/1.txt.
    • It also prints the values of avg perplexity scores and perplexity scores in seperate folder called scores.
    • The trained model is also stored in models folder .
  • Implemented Linear Interpolation
    • For training this on 1.txt - python3 language_model.py i ./corpus/1.txt.
    • It also prints the values of avg perplexity scores and perplexity scores in seperate folder called scores.
    • The trained model is also stored in models folder .

generator.py

Predict the next word for trained models of good turing , linear interpolation and without smoothing techniques.

  • Without smoothing
    • For running it python3 generator.py ./corpus/1.txt k.
  • For good turing model
    • For running it python3 generator.py g ./corpus/1.txt k.
  • For Linear Interpolation model
    • For running it python3 generator.py i ./corpus/1.txt k.

Note :- Here k can be any natural number . It gives the most probable k words.
Note :- First train the models (run language_model.py) then generate(generator.py) because then onle models.py is full

languagemodelling-and-tokenization's People

Contributors

mallasailesh 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.