Sanskrit meter identification and analysis library
Project description
Chanda
Sanskrit Meter Identification and Analysis Library
A comprehensive Python library for identifying and analyzing Sanskrit poetic meters. Supports 200+ meters including Sama-vṛtta, Ardhasama-vṛtta, Viṣama-vṛtta, and Mātrā-vṛtta.
- Chandojñānam Web Interface: https://sanskrit.iitk.ac.in/jnanasangraha/chanda/
- Chandojñānam Web Interface Source Code: https://github.com/hrishikeshrt/chandojnanam/
Features
-
200+ Meter Database: Comprehensive coverage of Sanskrit meters
- Sama-vṛtta (meters with identical padas)
- Ardhasama-vṛtta & Viṣama-vṛtta (meters with varying padas)
- Mātrā-vṛtta (matra-based meters like Āryā, Gīti)
-
Smart Identification:
- Exact pattern matching
- Fuzzy matching with syllable-level correction suggestions
- Verse-level analysis (4-line grouping)
-
Multi-Script Support: 15+ scripts and transliteration schemes
- Devanagari, IAST, ITRANS, Harvard-Kyoto, SLP1, WX, Velthuis, and more
-
Detailed Analysis:
- Syllable segmentation
- Laghu-Guru (light-heavy) marking
- Gana notation conversion
- Mātrā (morae) counting
- Jāti (classification) identification
Installation
From PyPI
pip install chanda
From Source
git clone https://github.com/hrishikeshrt/chanda.git
cd chanda
pip install -e .
Quick Start
Python API
from chanda import identify_meter
# Identify meter from a single line
text = "इक्ष्वाकुवंशप्रभवो रामो नाम जनैः श्रुतः"
result = identify_meter(text)
print(result['display_chanda']) # Output: Anuṣṭup (पाद 1)
print(result['display_gana']) # Output: नभजलगलग
print(result['matra']) # Output: 32
Command-Line Interface
# Analyze a single line
chanda "इक्ष्वाकुवंशप्रभवो रामो नाम जनैः श्रुतः"
# Analyze a file
chanda -f bhagavad_gita.txt --verse --summary
# Interactive mode
chanda -i
# Get help
chanda --help
Detailed Usage
Single Line Analysis
from chanda import identify_meter
text = "रामो राजमणिः सदा विजयते रामं रमेशं भजे"
result = identify_meter(text, fuzzy=True)
if result['found']:
print(f"Meter: {result['display_chanda']}")
print(f"Syllables: {result['syllables']}")
print(f"Pattern (LG): {' '.join(result['lg'])}")
print(f"Gana: {result['gana']}")
print(f"Syllable count: {result['length']}")
print(f"Mātrā count: {result['matra']}")
else:
# Check fuzzy matches
if result['fuzzy']:
best_match = result['fuzzy'][0]
print(f"Closest meter: {best_match['display_chanda']}")
print(f"Similarity: {best_match['similarity']:.2%}")
Verse Analysis
from chanda import analyze_text
verse = """इक्ष्वाकुवंशप्रभवो रामो नाम जनैः श्रुतः।
मामकाः पाण्डवाश्चैव किमकुर्वत सञ्जय॥"""
results = analyze_text(verse, verse_mode=True, fuzzy=True)
# Access verse-level results
for verse in results['result']['verse']:
best_meters, score = verse['chanda']
print(f"Verse meter: {' / '.join(best_meters)} (score: {score})")
Documentation
Full documentation is available at chanda.readthedocs.io
Project Structure
chanda/
├── chanda/ # Main package
│ ├── __init__.py # Public API
│ ├── core.py # Core Chanda class
│ ├── utils.py # Utility functions
│ ├── cli.py # Command-line interface
│ ├── exceptions.py # Custom exceptions
│ └── data/ # Meter definitions (CSV files)
├── examples/ # Usage examples
├── docs/ # Sphinx documentation
├── pyproject.toml # Package configuration
├── setup.py # Setup script
├── Makefile # Build and test automation
└── README.md # This file
Supported Meters
Sama-vṛtta (348 meters)
Anuṣṭup, Indravajrā, Upendravajrā, Vasantatilakā, Mālinī, Śārdūlavikrīḍita, and 340+ more
Ardhasama/Viṣama-vṛtta (52 meters)
Aparavaktra, Upacitra, Viyoginī, and 49+ more
Mātrā-vṛtta (10 meters)
Āryā, Āryāgīti, Udgīti, Upagīti, Gīti, and 5+ more
Web Interface
A web interface built with Flask is available separately at: https://github.com/hrishikeshrt/chanda
Live demo: https://sanskrit.iitk.ac.in/jnanasangraha/chanda/
Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes with tests
- Run the test suite
- Submit a pull request
Citation
If you use Chanda in your research, please cite:
@software{chanda2025,
title = {Chanda: Sanskrit Meter Identification Library},
author = {Terdalkar, Hrishikesh},
year = {2025},
url = {https://github.com/hrishikeshrt/chanda}
}
License
MIT License - see LICENSE file for details.
Acknowledgments
- Based on traditional chandaśāstra texts
- Meter definitions compiled from various classical sources
- Built on the excellent
sanskrit-textandindic-transliterationlibraries
Links
- PyPI: https://pypi.org/project/chanda/
- GitHub: https://github.com/hrishikeshrt/chanda
- Documentation: https://chanda.readthedocs.io
- Issues: https://github.com/hrishikeshrt/chanda/issues
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
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 chanda-0.1.0.tar.gz.
File metadata
- Download URL: chanda-0.1.0.tar.gz
- Upload date:
- Size: 51.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
69f17bd0f50c014ac293f46dc7cb734f69e5f679cf8de6ca4c05cc34892f7ea4
|
|
| MD5 |
aaf1e8329ef3ea2858559a1fb89dbe65
|
|
| BLAKE2b-256 |
a9cea7ec5e860c431ddb64ba7bc4ba1d785de490fce07282df52be3cf04c3b1f
|
File details
Details for the file chanda-0.1.0-py3-none-any.whl.
File metadata
- Download URL: chanda-0.1.0-py3-none-any.whl
- Upload date:
- Size: 38.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a56257f1dd640d654cd20c847b1961b69b676916dce4aa12590d1fd3eedbd5dc
|
|
| MD5 |
b676c2f8eecb49d4e885008f0bb2a7d7
|
|
| BLAKE2b-256 |
b9f51ea36160ced6f57f31158dea671e2b2877683e33147d81e88d1453910abf
|