Skip to content

Commit

Permalink
WIP: dhatu_metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
akprasad committed Jan 17, 2025
1 parent e9d89cb commit 900df4b
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 0 deletions.
1 change: 1 addition & 0 deletions vidyut-data/scripts/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.13
Empty file added vidyut-data/scripts/README.md
Empty file.
41 changes: 41 additions & 0 deletions vidyut-data/scripts/fetch_dhatu_metadata.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"""Creates dhatu metadata based on data from ashtadhyayi.com.
Usage:
uv run fetch_dhatu_metadata.py
"""


import json
import pprint
import urllib.request
from vidyut.lipi import transliterate, Scheme


def load_metadata() -> dict:
url = "https://github.com/ashtadhyayi-com/data/raw/refs/heads/master/dhatu/data.txt"
f = urllib.request.urlopen(url)
return json.load(f)


data = load_metadata()
dhatus = data["data"]

for dhatu in dhatus:
artha_en = dhatu["artha_english"]
artha_hi = dhatu["artha_hindi"]
code = dhatu["baseindex"]
karma = dhatu["karma"]
pada = dhatu["pada"]
settva = dhatu["settva"]

assert karma in {"S", "A", "D", '-'}, karma
assert pada in {"P", "A", "U", '-'}, pada
assert settva in {"S", "A", "V", '-'}, settva

if karma == '-':
assert karma == pada == settva == '-'
pprint.pprint(dhatu)
continue


9 changes: 9 additions & 0 deletions vidyut-data/scripts/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[project]
name = "scripts"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.13"
dependencies = [
"vidyut>=0.3.1",
]
47 changes: 47 additions & 0 deletions vidyut-data/scripts/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 900df4b

Please sign in to comment.