Train and predict string entropy based on character n-grams
Project description
Pytropic
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.1.1.tar.gz
(4.6 kB
view details)
Built Distribution
File details
Details for the file pytropic-1.1.1.tar.gz
.
File metadata
- Download URL: pytropic-1.1.1.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.2 CPython/3.10.8 Darwin/22.2.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | df8b66117af9d0fa734b1a42806ec74e3db66a373e14a371853e4f6878d0e175 |
|
MD5 | 3f244f989c2d28c1e008cabe695a6d5a |
|
BLAKE2b-256 | 2ceed92c075066f5860bd404920f1f113d69f8585ef53961f41724bfe20181c3 |
File details
Details for the file pytropic-1.1.1-py3-none-any.whl
.
File metadata
- Download URL: pytropic-1.1.1-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.2 CPython/3.10.8 Darwin/22.2.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7fa92cee55f7d679210d29cf88878e2cfb106af7ce554aaa63cc91fb590114b2 |
|
MD5 | 74f8f06b606c3a55933542819190ba24 |
|
BLAKE2b-256 | 2e1d167b3e5e33cf89be69895079bc6a3462cbebf13fa6842dd3afe8be433626 |