Giter VIP home page Giter VIP logo

shannon_game's Introduction

Shannon Game for Human Language Model Entropy

This project implements a simple Shannon game to estimate the entropy of human language models, for my NLP class (Fall 2022, Oregon State).

It was inspired by the Java Applet from UCSD's Math 187 class (Cryptography, Spring 2014) by Prof. Adriano Garsia. Since Java Applets have become obsolete, I wrote this very simple Python tool as a replacement for my students. It uses ANSI escape sequences for cursor movement.

Installation

This package uses the readchar library.

pip3 install -r requirements.txt

Usage

On a Linux/Mac terminal (better with wide screen), run

python3 shannon_game.py [<text_file>]

If the argument is missing, test.txt is used by default.

A typical screenshot is:

Welcome to the Shannon Game! Please guess!
118 chars remaining
EVEN THOUGH YOU _
2           2
01121413411161117
[-BCD-FGHIJKL-NOPQ--TUV-XYZ-]
entropy in range [1.44, 1.80]

Entropy Estimation

This project uses Shannon's original estimates of the lowerbound and the upperbound, but using N=1 (i.e., unigram guess sequence).

Author

Liang Huang ([email protected])

shannon_game's People

Contributors

lianghuang3 avatar

Stargazers

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