Skip to main content

Python dictionaries support for Plover

Project description

Plover Python dictionary

Add support for Python dictionaries to Plover.

Usage

A Python dictionary is simply a single module with the following API:

# Length of the longest supported key (number of strokes).
LONGEST_KEY = 1

# Lookup function: return the translation for <key> (a tuple of strokes)
# or raise KeyError if no translation is available/possible.
def lookup(key):
    assert len(key) <= LONGEST_KEY
    raise KeyError

# Optional: return an array of stroke tuples that would translate back
# to <text> (an empty array if not possible).
def reverse_lookup(text):
    return []

For example save the following code to show_stroke.py:

LONGEST_KEY = 2

SHOW_STROKE_STENO = 'STR*'

def lookup(key):
    assert len(key) <= LONGEST_KEY, '%d/%d' % (len(key), LONGEST_KEY)
    if SHOW_STROKE_STENO != key[0]:
        raise KeyError
    if len(key) == 1:
        return ' '
    return key[1]

Then add it to your dictionaries stack as you would a normal dictionary.

Now, if you stroke STR*, then the next stroke will be shown verbatim (untranslated), e.g. -T STROEBG TP-R KW-GS STROEBG KR-GS S STR* STROEBG outputs: the stroke for "stroke" is STROEBG.

Release history

0.5.12

  • update changelog...

0.5.11

  • drop support for Python < 3.6
  • fix use of deprecated imp module
  • rework tests to use plover_build_utils.testing
  • use PEP 517/518

0.5.10

  • fix ./setup.py test handling
  • fix default implementation of reverse_lookup to return a list (not a tuple)

0.5.9

  • update to Plover's latest API

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

plover_python_dictionary-0.5.12.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file plover_python_dictionary-0.5.12.tar.gz.

File metadata

  • Download URL: plover_python_dictionary-0.5.12.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for plover_python_dictionary-0.5.12.tar.gz
Algorithm Hash digest
SHA256 6cca3a0c4a971030e41c5f1c8f6c81b40a1e01e753384f92ce865b1a5d3c807a
MD5 a1663283a7ae241ee35fd81d46e3f27b
BLAKE2b-256 32efdf57a92cf3ac3656e496f64cbc2d9eccd2f33f4efc03a467a4d8e8b98fb2

See more details on using hashes here.

File details

Details for the file plover_python_dictionary-0.5.12-py3-none-any.whl.

File metadata

  • Download URL: plover_python_dictionary-0.5.12-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for plover_python_dictionary-0.5.12-py3-none-any.whl
Algorithm Hash digest
SHA256 2611d50013e826ddaa9b6cefa533377cd459b5de3cc115093cc6596b4d1b3419
MD5 e94553c7caad602750738724c22e584f
BLAKE2b-256 20ad8fbaabc01769535042b62e18a30dda27905a9337f976cbd00409b8a62a9d

See more details on using hashes here.

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