Convert text to adjective-noun mnemonics.
Project description
🧠 nemony
Deterministically encode text as mnemonic adjective-noun pairs.
The same text should be identically encoded across systems. While there are currently more than 800,000 combinations of adjective and noun, collisions (two texts having the same mnemonic) can happen.
Installation
The easy way
Install the pre-compiled version from PyPI:
pip install nemony
From source
Clone the repository, then cd
into it. Then run:
pip install -e .
Usage
Command line
You can use nemony to encode lines of text from a file
(the header info goes to stderr
).
$ printf 'hello\nworld' > tmp.txt
$ nemony tmp.txt
## MNEMO: Generate adjective-noun mnemonics
Word list version: fancy_telecom
- Number of adjectives: 581
- Number of nouns: 1450
- Combinations: 842450
decorous_block
late_kevin
Or pipe from from stdin
.
$ printf 'hello\nworld' | nemony
## MNEMO: Generate adjective-noun mnemonics
Word list version: fancy_telecom
- Number of adjectives: 581
- Number of nouns: 1450
- Combinations: 842450
decorous_block
late_kevin
You can also run interactively to check one thing at a time. Bear in mind that this encodes the whole text, not one line a time.
$ nemony -i
## MNEMO: Generate adjective-noun mnemonics
Word list version: fancy_telecom
- Number of adjectives: 581
- Number of nouns: 1450
- Combinations: 842450
(Ctrl-C to exit.)
What would you like to encode?
?> hello
decorous_block
?> world
late_kevin
?> hello\nworld
warm_dominic
usage: nemony [-h] [--interactive] [--output [OUTPUT]] [input]
Encode lines of text deterministically as adjective-noun mnemonics.
positional arguments:
input File to read and emit one mnemonic per line. Default STDIN.
options:
-h, --help show this help message and exit
--interactive, -i Run interactively.
--output [OUTPUT], -o [OUTPUT]
Output file. Default STDOUT.
Python API
You can import nemony and use it to encode Python objects, as long as they can be converted to strings.
>>> import nemony as nm
>>> nm.encode('world', sep='-')
'late-kevin'
>>> nm.encode('world', sep='-', n=5)
'peppy-gabriel'
>>> nm.encode(5.)
'live_drum'
>>> nm.encode(['hello', 'world'])
'receding_cheese'
As a convenience, you can also use the SHA-256 hashing functions
(which use Python standard library hashlib
).
>>> nm.hash('world')
'486ea46224d1bb4fb680f34f7c9ad96a8f24ec88be73ea8e5a6c65260e9cb8a7'
>>> nm.hash('world', n=8)
'486ea462'
>>> nm.hash(5., n=8)
'a19a1584'
Documentation
Check the Python API at ReadTheDocs.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file nemony-0.0.2.tar.gz
.
File metadata
- Download URL: nemony-0.0.2.tar.gz
- Upload date:
- Size: 17.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fffb99721910caea5ee6bfc57483b49d68aeadd0beb974145a887ea4f4645080 |
|
MD5 | a05cc74e08f5c468e48e32168acd7d87 |
|
BLAKE2b-256 | f6965bbe63e3ea3103cdc7ca951e0d143f0b7201726868fcf6adffe62c63700a |
File details
Details for the file nemony-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: nemony-0.0.2-py3-none-any.whl
- Upload date:
- Size: 16.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1dcac87d1d472e3264a428e7bc43fc6fc51351e8eef5690e6024224e9b466284 |
|
MD5 | 7f6dc706a5844e995e6238ce3a973d7a |
|
BLAKE2b-256 | 38477bc5565e920e9e3d04f6cb89e90d12e3d6ed010389e8465c93458c15f07d |