Skip to main content

Python dictionaries support for Plover

Project description

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.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.10.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

File details

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

File metadata

File hashes

Hashes for plover_python_dictionary-0.5.10.tar.gz
Algorithm Hash digest
SHA256 1466b23867dfd50140ef5165e3606ff8f50e3bef32560672221df63eb966c77d
MD5 e8137dcd2230a1a92b326603892bea7e
BLAKE2b-256 0783aefdabac2f8b7670739edd1fda08b14daf1908d788fb34a84c6b52ba2ed2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plover_python_dictionary-0.5.10-py3-none-any.whl
Algorithm Hash digest
SHA256 ed023236637177a7464883fe94a25f5e19e9b8cd60ef404ce3bd4e83be71a5c3
MD5 5440e24a570345d076aa617cdd75c00f
BLAKE2b-256 df6908e9dd31bf9d51176c91c338b06dc61e40e152512b09db9bc94d6e4525f1

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