Skip to main content

Performs metrical analysis on ISO-15919-transliterated Sanskrit verses

Project description

viracitapada

Tests Status Tests Coverage mypy

Performs metrical analysis on ISO-15919-transliterated Sanskrit verses.

Features

  • usable as a library in arbitrary projects (no CLI included, yet)
  • parses lines of text into a metrical notation of long/short markers via parse_meter (see examples below)
  • annotates the tokens of lines of text with their metrical position via annotate_metrical_pos (see examples below)

[!NOTE] The way this library is implemented is quite naive – it uses simple string replacements matching regular expressions. This is (widely known to be) not the fastest approach to parsing things and while it probably won't be a problem in one-off applications like data transformation scripts or pipelines, it might show if used in user-facing applications that process very large amounts of data. The operations that are performed are still very trivial, so to find out if the performance is good enough for your use case, you should just give it a try.

Usage

parse_meter as well as annotate_metrical_pos will return the same type of data you threw at them. This can be either a single line of text as a str ("line one"), multiple lines of text as a str ("line one\nline two\nline three") or a list[str] containing a line of text per string (["line one", "line two", "line three"]).

Some examples:

import viracitapada as vp

vp.parse_meter("agním īḷe puróhitaṁ")
# —◡ —— ◡—◡—

vp.parse_meter("úṣo yé te ̀ prá yā́meṣu yuñjáte")
# ◡— — — · ◡ ——◡ —◡— (" `" as pause)

vp.parse_meter(
    "kadā́ vaso ̀ stotráṁ háryate ā́",
    long_mark="L",
    short_mark="S",
    pause_mark="P",
)
# "SL SL P LL LSL L"

vp.parse_meter("agním īḷe puróhitaṁ\nyajñásya devám r̥tvíjam\nhótāraṁ ratnadhā́tamam")
# —◡ —— ◡—◡—\n——◡ —◡ —◡—\n——— —◡—◡—

vp.parse_meter([
    "agním īḷe puróhitaṁ",
    "yajñásya devám r̥tvíjam",
    "hótāraṁ ratnadhā́tamam",
])
# ["—◡ —— ◡—◡—", "——◡ —◡ —◡—", "——— —◡—◡—"]

vp.annotate_metrical_pos("agním īḷe puróhitaṁ")
# 1_agním 3_īḷe 5_puróhitaṁ

vp.annotate_metrical_pos(
    "agním īḷe puróhitaṁ\nyajñásya devám r̥tvíjam\nhótāraṁ ratnadhā́tamam"
)
# 1_agním 3_īḷe 5_puróhitaṁ\n1_yajñásya 4_devám 6_r̥tvíjam\n1_hótāraṁ 4_ratnadhā́tamam

vp.annotate_metrical_pos([
    "agním īḷe puróhitaṁ",
    "yajñásya devám r̥tvíjam",
    "hótāraṁ ratnadhā́tamam",
])
# ["1_agním 3_īḷe 5_puróhitaṁ", "1_yajñásya 4_devám 6_r̥tvíjam", "1_hótāraṁ 4_ratnadhā́tamam"]

Development

This project uses uv to manage dependencies. Install uv to make use of the following commands.

Install library and dependencies in a local virtual environment:

uv sync

Check code formatting, run linter:

uv run ruff format . --check
uv run ruff check .

Format code and fix linter errors:

uv run ruff format .
uv run ruff check . --fix

Run mypy to check typing:

uv run mypy

Run tests and measure test coverage:

uv run coverage run -m pytest

Run specific tests file:

uv run coverage run -m pytest tests/test_clean.py

Print coverage report of last measured test run:

uv run coverage report -m

Run everything from above to make sure things are working and in good shape (on Unix-like systems):

./pre-commit.sh

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

viracitapada-0.1.1.tar.gz (21.8 kB view details)

Uploaded Source

Built Distribution

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

viracitapada-0.1.1-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file viracitapada-0.1.1.tar.gz.

File metadata

  • Download URL: viracitapada-0.1.1.tar.gz
  • Upload date:
  • Size: 21.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.7

File hashes

Hashes for viracitapada-0.1.1.tar.gz
Algorithm Hash digest
SHA256 4ef9ea8bd04a5eda5f544e9515572bfad3d42f5f1d468b3e94ca59f35e8600bb
MD5 56f8f1ba4d677ccc8fd48d3da2ff4527
BLAKE2b-256 cfc239569b409fce0f661329ece7e06646b3deb53bf28f6f74405837e1d36abe

See more details on using hashes here.

File details

Details for the file viracitapada-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for viracitapada-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0b648ebaf6fa7090534908dc691cb1b0de3c820812e824a8533c833d2998049a
MD5 e379d27514cad9b66b932bec3fec085f
BLAKE2b-256 146a6c64383815c94f14755336b9554d036518a23835d3d6bbd2ffc0a4b26af1

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