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 UTF-8 source file 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:
Note: make sure the file encoding is UTF-8!
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
1.2.0
- use importlib instead of exec (#12)
1.1.0
- fix type checks for
lookupandreverse_lookup: allow bound methods and functors - fix
reverse_lookupimplementation: return a set. - fix
__getitem__/getimplementations: when the key length is out of bounds - fix
__contains__implementation - fix
__delitem__/__setitem__implementations: raise the correct exception type
1.0.0
- fix possible encoding issue when loading a dictionary: from now on, assume and force UTF-8
0.5.12
- update changelog...
0.5.11
- drop support for Python < 3.6
- fix use of deprecated
impmodule - rework tests to use
plover_build_utils.testing - use PEP 517/518
0.5.10
- fix
./setup.py testhandling - fix default implementation of
reverse_lookupto return a list (not a tuple)
0.5.9
- update to Plover's latest API
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file plover_python_dictionary-1.2.1.tar.gz.
File metadata
- Download URL: plover_python_dictionary-1.2.1.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a0215445c28fcbfd56f5acafbe8f5c5a7dfbfc51a49c5de7caa52f2f93f223d
|
|
| MD5 |
0c9ea94f54959f62e0e5c516a28075da
|
|
| BLAKE2b-256 |
ea3c7480c96d9d6b41dbbfe0867358a62f6919d1a00872e7d53c4f2a85bda71f
|
File details
Details for the file plover_python_dictionary-1.2.1-py3-none-any.whl.
File metadata
- Download URL: plover_python_dictionary-1.2.1-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5abaf55f72a95cfeee8e60f4f4722ac664fdd8ea0b3d817341ba012c360cae2b
|
|
| MD5 |
e331d1eddfc11bd3a58e6e83bfd992c8
|
|
| BLAKE2b-256 |
38debe4e035ed091c31959bde4384c54833b149b133b08451ebfa04b5de0e450
|