Skip to main content

lekhaka

lekhaka (लेखक, a scribe) turns a printed book of verses into its chapters. Each page is read by a vision model through vishalakshi, local or hosted, as blocks: verses with their printed numbers, headings, colophons. lekhaka gathers the verses into chapters, mends the numbering slips a reader makes, repairs malformed Devanagari akṣaras, and lists what a proofreader should check.

Install

pip install lekhaka

How to use

from lekhaka import read_book, book_md
from vishalakshi import Vault

b = read_book('gita.pdf', Vault('books.db'), model='claude/sonnet', title='Bhagavad Gita',
              hint='Each verse ends in ॥ n ॥.', counts=[47, 72])
b.chapters[0]['verses'][:2]     # [{n, text, page, heading}, ...]
b.probs                         # numbers mended, counts that differ, for a proofreader
print(book_md(b.chapters, 'Bhagavad Gita'))

With a vault the pages are kept as versions of one document: vault.proofread(b.doc_id, readers) has other models read them again, and vault.accept applies the changes the owner chooses. Without a vault nothing is stored.

The pieces work on their own, on the pages vishalakshi.read_doc returns or any {page, blocks} list:

On real books

nbs/samples holds a few pages each of three books vedicreader has read, as a model returned them. Sixteen pages of Varāhamihira’s Bṛhajjātaka assemble into its third and fourth chapters, each opened by its heading and closed by its colophon:

import json
bj = json.load(open('samples/brihat_jataka.json'))
chs, probs = assemble(bj)
[(c['heading'], len(c['verses']), (c['colophon'] or '')[:40]) for c in chs]
[('वियोनिजन्माध्यायः', 8, 'इति श्रीवराहमिहिरकृते बृहज्जातके वियोनिज'),
 ('निषेकाध्यायः', 22, 'इति श्रीवराहमिहिरकृते बृहज्जातके निषेकाध')]
probs
[]

The Vidhānamālai prints each verse’s number at the end of its urai, the prose gloss after it. The urai goes into its verse’s notes, and gives the verse its number:

vm = json.load(open('samples/vidhanamalai.json'))
chs, probs = assemble(vm, notes=('urai',), number_from_note=True)
v = chs[0]['verses'][0]
len(chs[0]['verses']), v['n'], v['text'].split('\n')[0], v['notes']['urai'][0][:60]
(11,
 1,
 'பூமகள் கேள்வன்பொன் னுடையன் புட்கொடி யோன் புனித,',
 '(என்றது.) ஸ்ரீமகாலக்ஷ்மிக்கு நாயகரும், பீதாம்பரத்தையுடையவரும')

Uromarishi’s Pañcapakṣi (1917) numbers its verses in Tamil numerals with the old signs for ten and a hundred:

uro = json.load(open('samples/uromarishi.json'))
[(b['n'], vnum(b['n'])) for p in uro for b in p['blocks'] if '௱' in str(b.get('n') or '')][:4]
[('௨௱௫', 205), ('௨௱௬', 206), ('௨௱௭', 207), ('௨௱௮', 208)]

The pieces

fix_aksharas('ध्ार्म'), vnum('२६॥२७'), vnum('२६॥ १', pick='first')
('धार्म', 27, 26)

Metadata

Release files for lekhaka 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lekhaka 0.0.4
File Size Uploaded
lekhaka-0.0.4.tar.gz 13.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lekhaka 0.0.4
File Interpreter ABI Platform
lekhaka-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 28.8 kB

Release files / lekhaka-0.0.4.tar.gz

Download URL lekhaka-0.0.4.tar.gz
Size 13.6 kB
Tags Source
SHA-256 checksum
How to use checksums
91c035d7a05dac5b3788082c06c85a7e7be89194751db8314485fe99a047af85
BLAKE2b-256 checksum
How to use checksums
2bc832467d9609e26de6f0ecd06f2ced6005175145bf49054a8f97f6752a943c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / lekhaka-0.0.4-py3-none-any.whl

Download URL lekhaka-0.0.4-py3-none-any.whl
Size 15.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ba84bdc09179966b5cc7b3948a968eedaad520842ce223b935f15f94ff29bf90
BLAKE2b-256 checksum
How to use checksums
46ee259c86bc221529b026f58072360aef271ae09166fcb8cee6812ad3bd1f99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release history Release notifications | RSS feed

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

This release

0.0.4 This release

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page