Skip to content

Latest commit

 

History

History
57 lines (41 loc) · 2.09 KB

README.md

File metadata and controls

57 lines (41 loc) · 2.09 KB

Source code: Shannon, Shannon fano and Huffman

About

This little project is product of a class assignment, coded around March 2016.

It was used to study:

  • Obtention of a source of information from a text, where source of information consists in a list of pairs, where each pair contains one letter and its frequency of appearance in the given text.
  • Computation of the entropy of a source of information.
  • Creation of extensions from said source.
  • Implementation of Shannon coding.
  • Implementation of Shannon fano coding.
  • Implementation of Huffman coding.

Structure

It is composed by five files:

  • Shannon.py, which implements Shannon coding.
  • Shannon_fano.py, which implements Shannon fano coding.
  • Huffman.py, which implements Huffman coding.
  • Utils.py, which is the core and has all the important methods that lead to each implementation.
  • main.py, which allows a direct route to use the methods defined in Utils.py from the terminal.

How it works

You can read about what this project implements in the following wikipedia entries:

For each coding (Shannon, Shannon fano and Huffman), the mean length is provided too.

Usage

You can test quickly each coding executing main.py and providing it with a source file.

LICENSE

Copyright 2017 Laura C.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.