Skip to main content

ganapati

Metre, verse boundaries, citations, and lemmas. import ganapati registers the Sanskrit reader profiles, so a GRETIL or TEI source is chunked by verse and its tree is built from the citations.

from litesearch import Index
from ganapati import Meter

ix = Index('vault.db')
ix.add('mahabharata.htm')
ix.search('dharma')[:3]
ix.db.by_meter(meter=Meter.ANUSTUBH)[:3]
/Users/71293/code/personal/orgs/ganapati/.venv/lib/python3.13/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm

[{'content': 'nārāyaṇaṃ namaskṛtya naraṃ caiva narottamam\ndevīṃ sarasvatīṃ caiva tato jayam udīrayet',
  'metadata': '{"meter": "anuṣṭubh", "variant": "pathyā", "gana": "ta_ra_ga_ga", "pada": "8"}',
  'node_id': '73a63025c7fc3d14#0',
  'doc_id': '73a63025c7fc3d14',
  'page': 0},
 {'content': 'samāsīnān abhyagacchad brahmarṣīn saṃśitavratān\nvinayāvanato bhūtvā kadā cit sūtanandanaḥ',
  'metadata': '{"meter": "anuṣṭubh", "variant": "pathyā ra-vipulā", "gana": "ya_ta_ga_ga", "pada": "8"}',
  'node_id': '73a63025c7fc3d14#0',
  'doc_id': '73a63025c7fc3d14',
  'page': 2},
 {'content': 'tam āśramam anuprāptaṃ naimiṣāraṇyavāsinaḥ\ncitrāḥ śrotuṃ kathās tatra parivavrus tapasvinaḥ',
  'metadata': '{"meter": "anuṣṭubh", "variant": "pathyā", "gana": "ja_sa_ga_ga", "pada": "8"}',
  'node_id': '73a63025c7fc3d14#0',
  'doc_id': '73a63025c7fc3d14',
  'page': 3}]

Every chunk carries its metre as searchable metadata.

verse_meta('dharmakṣetre kurukṣetre samavetā yuyutsavaḥ '
           'māmakāḥ pāṇḍavāścaiva kimakurvata sañjaya')
{'meter': 'anuṣṭubh', 'variant': 'pathyā', 'gana': 'ma_ra_ga_ga', 'pada': '8'}

The scan behind it, and the metre that pattern names:

scan('dharmakṣetre kurukṣetre')     # g for heavy, l for light
'gggglggg'
detect_meter('kaścit kāntāvirahaguruṇā svādhikārātpramattaḥ '
             'śāpenāstaṃgamitamahimā varṣabhogyeṇa bhartuḥ '
             'yakṣaścakre janakatanayāsnānapuṇyodakeṣu '
             'snigdhacchāyātaruṣu vasatiṃ rāmagiryāśrameṣu')['name']
<Meter.MANDAKRANTA: 'mandākrāntā'>

The three modules

module what is in it
ganapati.text verse boundaries, the two chunkers, readers for GRETIL, TEI, VR XML and DCS
ganapati.metre IAST transliteration, syllable weights, the gaṇas, 80 metres, mātrā metres
ganapati.lemma vidyut lemmas, Monier-Williams glosses, the reader profiles

Install

pip install ganapati

Lemmas and glosses need vidyut and an 81 MB data download, both reached on first use. Without them a store still gets metre.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ganapati-0.0.1.tar.gz (25.3 kB view details)

Uploaded Source

Built Distribution

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

ganapati-0.0.1-py3-none-any.whl (26.7 kB view details)

Uploaded Python 3

File details

Details for the file ganapati-0.0.1.tar.gz.

File metadata

  • Download URL: ganapati-0.0.1.tar.gz
  • Upload date:
  • Size: 25.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for ganapati-0.0.1.tar.gz
Algorithm Hash digest
SHA256 b6ccf1933a756f519a8dfcf19407d4ffd3551675b873a38796aa7c559fba5a41
MD5 389f6329df6a0c68c7e7ad71b658fb9c
BLAKE2b-256 c92ac91c70bc085d336e31a89f6fdda5c45d717eb175c84911d6ef91b32deb4d

See more details on using hashes here.

File details

Details for the file ganapati-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: ganapati-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 26.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for ganapati-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 032a0023f76af73ee7899dcfec3acca68604037362901385903f50a92eaaea6c
MD5 a9a75a394a39c575dc28629c8e7036b8
BLAKE2b-256 866c604d7c108c30cda8926db3faf67a16994bb8074aaf10b7427985fbe2391f

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 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