Skip to main content

A Python toolkit for building constructed languages: glossary format & search, base-form reduction, POS tagging, and orthography.

Project description

conlangkit

CI CodeQL PyPI Python versions License

A Python toolkit for building constructed languages. It provides a glossary format and search engine, base-form reduction for English, part-of-speech tagging integration, an orthography transliterator, and phoneme/syllable primitives — plus a clk command-line tool for working with a language on disk.

Experimental: the phonotactic features (syllable.candidates, Lang.syllables) are partially implemented. Lang.syllables currently raises NotImplementedError; call syllable.candidates() directly if you need phonotactic syllable generation.

Name note: the import package is conlangkit. It is unrelated to the langkit project on PyPI (WhyLabs' LLM-monitoring library).

Install

pip install conlangkit      # or: uv add conlangkit

This installs the library and the clk command-line tool.

Quick example

from conlangkit.glossary import Glossary

g = Glossary.load("path/to/glossary.md")
print(f"{g.lemma_count} entries loaded")

# Find entries whose definition contains "fruit"
for entry in g.find("d:*fruit", max_hits=10):
    print(entry.lemma, "—", entry.defn)

# Fuzzy search across lemma and definition
hits = g.find("apple", try_fuzzy=True)

Glossary files are Markdown tables with four pipe-delimited columns — lemma | tags | definition | notes — and may have arbitrary Markdown before and after the table. See ARCHITECTURE.md for the full format.

Command-line tool

clk <LANGDIR> repl      # interactive REPL over the language in <LANGDIR>
clk <LANGDIR>           # defaults to the repl
clk help                # general help

<LANGDIR> is a directory containing a language (cfg.json + glossary.md).

Public API

The supported surface (imported directly from its submodule):

Name Module Purpose
Glossary conlangkit.glossary Load, save, and search a glossary file
Entry conlangkit.glossary A single glossary entry (lemma, tags, defn, notes)
Defn / DefnItem conlangkit.glossary Parsed definition with multiple equivalences
SearchExpr / MatchExpr conlangkit.glossary Search-expression objects
Lang conlangkit.lang Language object: config + glossary + phonology
TranslationCoach / rewrite_rules conlangkit.tcoach Hint-based translation assistant
bfr conlangkit.bfr Base-form reduction (inflected English → lemma)
find_by_nltk conlangkit.pos Map an NLTK POS tag to a conlangkit POS
Orthography conlangkit.ortho Bidirectional transliteration
Syllable / candidates conlangkit.syllable Phonotactic primitives (experimental)
Phoneme / ByIPA / ByXSampa conlangkit.phoneme IPA phoneme inventory (experimental)

The package ships a py.typed marker, so type checkers see its annotations.

Developer quickstart

Prerequisite: uv.

git clone https://github.com/dhh1128/conlangkit
cd conlangkit
uv sync                 # create .venv from uv.lock (incl. dev tools)

# One-time: fetch the NLTK corpora the tests use
uv run python -c "import nltk; [nltk.download(p, quiet=True) for p in \
  ['punkt','punkt_tab','averaged_perceptron_tagger','averaged_perceptron_tagger_eng','wordnet']]"

uv run pytest           # tests + coverage
uv run ruff check .     # lint
uv run mypy             # type-check
uv run pre-commit install   # enable pre-commit hooks (once)

See CONTRIBUTING.md for the contribution workflow and AGENTS.md for the conventions AI agents and developers follow here.

License

Apache-2.0.

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

conlangkit-0.1.0.tar.gz (51.0 kB view details)

Uploaded Source

Built Distribution

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

conlangkit-0.1.0-py3-none-any.whl (59.3 kB view details)

Uploaded Python 3

File details

Details for the file conlangkit-0.1.0.tar.gz.

File metadata

  • Download URL: conlangkit-0.1.0.tar.gz
  • Upload date:
  • Size: 51.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for conlangkit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b4d1eb94a25251bea65369e275af1272dfe1c09a3a0d04831c487ebad75b89ed
MD5 54661110f7dcb77083ff93e655eea570
BLAKE2b-256 671c659ccedbcb329321eca34ce82e9e2252273a15f6ff6dcd27025a4f8d904f

See more details on using hashes here.

Provenance

The following attestation bundles were made for conlangkit-0.1.0.tar.gz:

Publisher: release.yml on dhh1128/conlangkit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file conlangkit-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: conlangkit-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 59.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for conlangkit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e35f876f248ac776214b9fce7c4985e8bf54228e29adb096e516bd7ca630f873
MD5 e32615231c6f5abb47cb00f0260f895c
BLAKE2b-256 c7b939fe8de13d6ecc9661633ff63b53337cc0b6494daa91e7664824f077aa90

See more details on using hashes here.

Provenance

The following attestation bundles were made for conlangkit-0.1.0-py3-none-any.whl:

Publisher: release.yml on dhh1128/conlangkit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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