Skip to content

feat: Expose dhatu code in vidyut.kosha.DhatuEntry#222

Open
VedantMadane wants to merge 2 commits intoambuda-org:mainfrom
VedantMadane:feature/expose-dhatu-code
Open

feat: Expose dhatu code in vidyut.kosha.DhatuEntry#222
VedantMadane wants to merge 2 commits intoambuda-org:mainfrom
VedantMadane:feature/expose-dhatu-code

Conversation

@VedantMadane
Copy link

Summary

Fixes #164 - Exposes the Dhatupatha code (e.g., 01.0001 for भू) in the Python API's DhatuEntry class.

Implementation

Following the exact same pattern as #163 (artha field implementation), this PR adds the code field to make dhatu codes accessible from Python.

Changes

Modified vidyut-kosha/src/entries.rs

  1. Added code: Option<String> field to DhatuMeta struct
  2. Added code: Option<String> field to DhatuMetaBuilder struct
  3. Added code() accessor method to DhatuEntry
  4. Added code() builder method to DhatuMetaBuilder
  5. Updated build() method to include code field

Modified bindings-python/src/kosha/entries.rs

  1. Added code: Option<String> field to PyDhatuEntry struct with documentation
  2. Updated constructor to accept code parameter
  3. Updated __repr__() to include code in output
  4. Updated From<&DhatuEntry> implementation to map code field

Modified bindings-python/test/unit/kosha/test_entries.py

  1. Added test_dhatu_entry_with_code() test function
  2. Updated existing __repr__ tests to expect code=None in output

Example Usage

from vidyut.kosha import DhatuEntry
from vidyut.prakriya import Dhatu, Gana

bhu = Dhatu.mula("BU", Gana.Bhvadi)
entry = DhatuEntry(dhatu=bhu, clean_text="BU", code="01.0001", artha_sa="sattAyAm")

assert entry.code == "01.0001"  # Now accessible!

@VedantMadane VedantMadane force-pushed the feature/expose-dhatu-code branch from 75539c9 to 5f03725 Compare January 21, 2026 11:28
Fixes ambuda-org#164

Add code field to DhatuMeta and expose it through Python API

Following the same pattern as ambuda-org#163 (artha field implementation)
@VedantMadane VedantMadane force-pushed the feature/expose-dhatu-code branch from 5b2d497 to 3da6d74 Compare February 10, 2026 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose the dhatu number in vidyut.kosha.DhatuEntry

1 participant