uslap-query / Code_files /archive /batch_scripts /diwan_s39_batch_16.py
uslap's picture
Upload folder using huggingface_hub
7cc8e29 verified
Raw
History Blame Contribute Delete
2.77 kB
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Session 39 β€” Diwan Vol 3 Batch Write #16
Pages 231-247 (printed 233-249, PDF 1005-1021)
Content: Noun derivation grammar, Khaqan nazm, verb entries, drying
Run: python3 Code_files/diwan_s39_batch_16.py
"""
import sys, os
sys.path.insert(0, os.path.join(os.path.dirname(__file__)))
from uslap_handler import write_entry
KITAB = "kitab dhawat al-thalatha"
VOL = 3
def w(headword, gloss, page, section, wc="VERB", nazm=False, proverb=False):
data = {
"headword": headword, "aa_gloss": gloss,
"ms_page": page, "diwan_section": section,
"word_class": wc, "kitab": KITAB, "volume": VOL,
}
if nazm: data["has_nazm"] = 1
if proverb: data["has_proverb"] = 1
try:
r = write_entry(data, "WORD_DIWAN")
status = "OK" if r.get("success") else f"FAIL: {r.get('message', '')[:100]}"
print(f" {status}: {headword[:60]}")
return r.get("success", False)
except Exception as e:
print(f" ERR: {headword[:40]} β€” {e}")
return False
ok = fail = 0
def track(result):
global ok, fail
if result: ok += 1
else: fail += 1
# ─── p.235: noun derivation from verbs ────────────────────────────────
track(w("GRAMMAR: noun derivation from verbs (istinbaat)", "MAJOR GRAMMAR: al-asma tustanbat min al-af'al. Example chain: sudhni (verb: to lightning) β†’ sudhq (noun: lightning). sidhaqi (verb: to urinate) β†’ sidlak (noun: urine). Nouns derived from verbal roots", 235, "bab wa-naw fa'la β€” morphology", "GRAMMAR"))
# ─── p.240: Khaqan nazm + dialect note ────────────────────────────────
track(w("NAZM: khaaqaan taskat khadaa li-al-malk qatilasiini", "nazm β€” Khaqan was silent, deceived for the king, killed. daraba ala haamatihi bi-al-mawt. al-munhazim ghayyara lawnahu wa-ashnat bihi aduwwuhu. lughat al-ghuzziyya wa-qifjaaq", 240, "bab wa-naw fa'la", nazm=True))
# ─── p.245: wishing to stay, drying ──────────────────────────────────
track(w("al minda turghsadi", "tamanna al-iqaama hahuna β€” wishing to stay/reside here", 245, "bab wa-naw fa'la / (t)"))
track(w("qurghsidi", "tawajjaha al-shay li-al-jifaaf β€” thing directed toward drying", 245, "bab wa-naw fa'la / (q)"))
# ═══════════════════════════════════════════════════════════════════════
print(f"\n{'='*60}")
print(f" BATCH 16 COMPLETE: {ok} OK, {fail} FAIL (total {ok+fail})")
print(f"{'='*60}")