Skip to main content

Train and predict string entropy based on character n-grams

Project description

Pytropic

Python package

An python with a lot of entropy

Train and predict string entropy based on character n-grams

Features

  • Train a model on a corpus of text
  • multiple n-gram sizes
  • Can name models

Example

>>> from pytropic import pytropic

>>> en = pytropic.Model(name='English 3-gram', size=3)
>>> fr = pytropic.Model(name='French 3-gram', size=3)

>>> with open('./corpora/bible-english.txt') as f:
        en.train(f)
>>> with open('./corpora/bible-french.txt') as f:
        fr.train(f)

>>> t = {'en': en, 'fr': fr}

>>> min(t, key=lambda x: t[x].entropy("this is a test"))
Out: 'en'

>>> min(t, key=lambda x: t[x].entropy("c'est un test"))
Out: 'fr'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytropic-1.0.1.tar.gz (3.7 kB view hashes)

Uploaded Source

Built Distribution

pytropic-1.0.1-py3-none-any.whl (3.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page