Skip to main content

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 package

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).

>>> hash('world')
'486ea46224d1bb4fb680f34f7c9ad96a8f24ec88be73ea8e5a6c65260e9cb8a7'
>>> hash('world', n=8)
'486ea462'
>>> hash(5., n=8)
'a19a1584'

Documentation

Check the Python API here.

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

nemony-0.0.1.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

nemony-0.0.1-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

Details for the file nemony-0.0.1.tar.gz.

File metadata

  • Download URL: nemony-0.0.1.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for nemony-0.0.1.tar.gz
Algorithm Hash digest
SHA256 0d10d2ac0275d004aa553658720ad2834ae3c0d2de6976117103957d4a6d516d
MD5 c8d5eeddeed4c8ef3a3c4ee1acc15f24
BLAKE2b-256 0a7e20dccca3deab47d20425db1449a640c00009868f858ded70e3154f8d9807

See more details on using hashes here.

Provenance

File details

Details for the file nemony-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: nemony-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 15.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for nemony-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2e3f5b301f65f276a5c2de3cf15de0df7b2c399b97b1d361b03380711f501f5c
MD5 f93008dae93e2062836e0087ce083126
BLAKE2b-256 af413e5090828d50a3f63fa12120ad29f410627cbef0fff93429b2da8a52664f

See more details on using hashes here.

Provenance

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