grams
A Python library for managing the histograms of text corpuses.
Installation
Use the package manager pip to install grams.
pip install grams
Usage
import grams
# Generate a histogram from a list of sentences
hist = grams.Histogram(['A sentence here.',
'A sentence there.',
'A sentence anywhere.'])
# Generate a histogram from a text file
with open('corpus.txt', 'r') as file:
file_hist = grams.Histogram(file)
# Find the distance between histograms ∈ [0, 1]
similarity = hist.similarity(file_hist)
# Sample a random word weighted by its number of occurrences
word = hist.sample()
# Display word frequencies in the terminal
hist.visualize()
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Lorem : ▇▇▇▇ 4.00
# Ipsum : ▇▇▇▇ 4.00
# is : ▇ 1.00
# simply : ▇ 1.00
# dummy : ▇▇ 2.00
# text : ▇▇ 2.00
# of : ▇▇▇▇ 4.00
# the : ▇▇▇▇▇▇ 6.00
# printing : ▇ 1.00
# and : ▇▇▇ 3.00
# typesetting: ▇▇ 2.00
# industry : ▇ 1.00
# has : ▇▇ 2.00
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Create a distribution object from code coverage data
cov = grams.Covergram("Documents/.coverage")
# We can visualize our code coverage data as well.
cov.visualize()
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# __init__.py : ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 100.00
# grams.py : ▇▇▇▇▇▇▇▇▇▇▇▇ 25.00
# hashtable.py : ▇▇▇▇▇▇▇▇▇▇▇ 22.00
# linkedlist.py : ▇▇▇▇▇▇▇ 15.00
# online.py : ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 40.00
# stats.py : ▇▇▇▇▇▇▇▇▇▇ 21.00
# termgraph.py : ▇▇▇▇▇▇ 12.00
# utils.py : ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 31.00
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Our distribution also maintains some useful statistics
avg_code_cov = int(cov.mean)
frequency_standard_deviation = int(hist.std)
frequency_variance = int(hist.var)
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
License
Metadata
Release files for grams 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| grams-0.0.3.tar.gz | 19.0 kB | Without provenance | Details for grams-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| grams-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for grams-0.0.3-py3-none-any.whl |
Total release size: 55.7 kB
Release files / grams-0.0.3.tar.gz
| Download URL | grams-0.0.3.tar.gz |
|---|---|
| Size | 19.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cb91b4b6690fdebf9d04958face07b1fa5b0a76559c236754347700788345ec1
|
|
BLAKE2b-256 checksum How to use checksums |
585060f63ab8eed9d36ab2aa054e45f69c8a63adf045d803edaf238335a57f58
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0.post20191030 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.5
|
Release files / grams-0.0.3-py3-none-any.whl
| Download URL | grams-0.0.3-py3-none-any.whl |
|---|---|
| Size | 36.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
530fb26315be322bd15afc2c39357d03a99cf9ec106bc74929f2e951533beb1a
|
|
BLAKE2b-256 checksum How to use checksums |
e8d061ecd1ce1b2e82e03ef61b877ae60f3cd6fab2f5acbb895699c6e261ab0a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0.post20191030 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.5
|
Security for grams 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.