Skip to main content

Clafrica keyboard mapping for Nufi (Fe'éfě'e): converts ASCII shortcut sequences to Unicode characters

Project description

clafrica

Python library for the Clafrica keyboard input method — converts ASCII shortcut sequences into Nufi (Fe'éfě'e) Unicode characters.

Install

pip install clafrica

Quick start

from clafrica import apply_mapping, finalize_input

apply_mapping("af1 e2 n*")   # → "ɑ̀ é ŋ"
apply_mapping("eu3 af5")     # → "ə̄ ɑ̂"
finalize_input("eu3")        # → "ə̄"

API

apply_mapping(text)

Converts all Clafrica shortcuts in text to Unicode, preserving whitespace.

from clafrica import apply_mapping

apply_mapping("af1 e2 n*")   # → "ɑ̀ é ŋ"
apply_mapping("uu1 o*2")     # → "ʉ̀ ɔ́"
apply_mapping("N* O*")       # → "Ŋ Ɔ"
apply_mapping("eu3 af5")     # → "ə̄ ɑ̂"

Live-typing mode — pass preserve_ambiguous_trailing=True to leave the last token untouched while the user may still extend it:

apply_mapping("af", preserve_ambiguous_trailing=True)  # → "af"  (could become af1, af2…)
apply_mapping("af1")                                   # → "ɑ̀"

finalize_input(text)

Like apply_mapping but also resolves any trailing ambiguous shortcut — use this when the user confirms input (e.g. presses Enter or Space).

from clafrica import finalize_input

finalize_input("eu3")   # → "ə̄"
finalize_input("af1")   # → "ɑ̀"
finalize_input("n*")    # → "ŋ"

ClafricaEngine — advanced use

Instantiate the engine directly for a custom mapping or extra entries.

from clafrica import ClafricaEngine

# Add project-specific shortcuts on top of the default table
engine = ClafricaEngine(extra={"nkap": "ŋkɑ̄p"})
engine.apply_mapping("nkap e2")   # → "ŋkɑ̄p é"
engine.finalize_input("eu3")      # → "ə̄"
engine.lookup("af1")              # → "ɑ̀"
engine.lookup("xyz")              # → None

# Fully custom table (replaces the default)
engine = ClafricaEngine(mapping={"a1": "à", "e1": "è"})

Shortcut reference

Shortcut Output Notes
af ɑ open-a
eu ə schwa
ai ε epsilon
o* ɔ open-o
uu ʉ u-bar
u- ʉ u-bar (alternative)
n* ŋ eng
N* Ŋ Eng (uppercase)
b* ɓ implosive b
d* ɗ implosive d
*n ɲ palatal n
a1 a2 a3 à á ā low / mid / high tone
a5 a7 â ǎ rising / falling tone
af1 af2 af3 ɑ̀ ɑ́ ɑ̄ open-a tones
eu1 eu2 eu3 ə̀ ə́ ə̄ schwa tones
ai1 ai2 ai3 ɛ̀ έ ɛ̄ epsilon tones
o*1 o*2 o*3 ɔ̀ ɔ́ ɔ̄ open-o tones
uu1 uu2 uu3 ʉ̀ ʉ́ ʉ̄ u-bar tones

Tone digits: 1 = low, 2 = mid, 3 = high, 5 = rising, 7 = falling.

Phrase shortcuts (space-terminated)

These require a trailing space to trigger:

Type Output
af ɑ
eu ə
ai ε
uu ʉ

Notes

  • ASCII-only shortcuts are matched case-insensitively (AF1 = af1).
  • Unicode shortcuts (e.g. à2, ɑ́1) are case-sensitive.
  • The mapping table is the canonical one used by the Nufi Android and Windows keyboards.

License

MIT

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

clafrica-1.0.1.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

clafrica-1.0.1-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file clafrica-1.0.1.tar.gz.

File metadata

  • Download URL: clafrica-1.0.1.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for clafrica-1.0.1.tar.gz
Algorithm Hash digest
SHA256 36a4fc350feb92975985d4f9aae1ebf98119bbcbe23e0f0c0fc90b770ea826c2
MD5 75ceaac628d276297354d500c0224d42
BLAKE2b-256 81d7be14016e9db1893431b0150fa3fa9af31db6ec56f7748e9b8c3ef9051b5c

See more details on using hashes here.

File details

Details for the file clafrica-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: clafrica-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for clafrica-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 073f39c1c360911106eb621cc621c54179ac16ffc733935811df61bd1028d9e2
MD5 c3e26776de103be9ffe1b7cf624548bc
BLAKE2b-256 a435e849b29ea9b820dbb6763ca8bca31f145d1907e7a563e7b4fe4e0c34a868

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page