#!/usr/bin/env python3 """Final batch: populate all remaining 1-token root meanings.""" import sqlite3 try: from uslap_db_connect import connect as _uslap_connect _HAS_WRAPPER = True except ImportError: _HAS_WRAPPER = False import os DB_PATH = os.path.join(os.path.dirname(__file__), "uslap_database_v3.db") FINAL_ROOTS = { "أدد": "Iram, a people, a pillar", "ألت": "to diminish, to reduce, to wrong", "أمت": "an unevenness, a depression, curved", "أنم": "cattle, livestock, grazing animals", "أود": "to bend, to burden, to weigh down", "أيم": "a widow, unmarried, without spouse", "ازر": "to support, to strengthen, a wrap", "بأر": "a well, a cistern", "بتر": "to cut off, severed, without posterity", "بتك": "to cut, to slit, to sever", "بجس": "to gush forth, to flow, a spring", "بحث": "to search, to investigate, to dig", "بسق": "to be tall, lofty, towering", "بغل": "a mule", "بقع": "a place, a spot, a location", "بقل": "herbs, vegetables, greens", "بلل": "to wet, to moisten, moisture", "بهل": "to curse, mutual imprecation", "بيد": "except, however, despite", "ترق": "a collarbone, to ascend", "تعس": "to stumble, to perish, misery", "تفث": "ritual uncleanliness, dirt of pilgrimage", "تقن": "to perfect, Salsabil (a spring in paradise)", "تلل": "a hill, to throw down, to prostrate", "تين": "a fig, figs", "تيه": "to wander, confusion, lost", "ثبط": "to hold back, to discourage, to hinder", "ثبي": "a group, a crowd, bands", "ثجج": "to pour heavily, flowing, gushing", "ثري": "moist earth, soil, dust", "ثيب": "a previously married woman", "جبت": "an idol, a false deity, sorcery", "جبه": "a forehead, to brand", "جثث": "to uproot, to pull out", "جذو": "a firebrand, a burning coal", "جرع": "to swallow, a gulp, a sip", "جرف": "to sweep away, a brink, undermined", "جسس": "to spy, to search, espionage", "جفأ": "to cast away, foam, scum", "جفن": "a bowl, a basin, a trough", "جفو": "to be harsh, to shun, rough", "جمح": "to bolt, to be headstrong, to rush", "جمد": "to freeze, to be rigid, solid", "جمم": "to be abundant, a multitude", "جوس": "to traverse, to go through, to roam", "جوو": "the atmosphere, the sky, air", "جيد": "a neck, a throat", "حبك": "to weave tightly, woven, paths", "حثث": "to urge, to hasten, to encourage", "حرد": "to be angry, to be determined, determined", "حرس": "to guard, guards, shooting stars", "حرك": "to move, to shake, motion", "حري": "to be worthy, to be fitting", "حسم": "to cut off, to settle, consecutive", "حصحص": "to become clear, truth revealed", "حصل": "to collect, to be gathered, extracted", "حفد": "to serve, to hasten, grandchildren", "حقف": "a sand dune, curved sand, al-Ahqaf", "حنذ": "to roast, roasted, well-cooked", "حنك": "to control, the palate, experienced", "حوب": "a sin, a great sin, injustice", "حوز": "to drive, to gather, to seize", "حيد": "to turn aside, to deviate", "حير": "to be confused, confusion, bewildered", "حيف": "to be unjust, injustice, to deviate", "خبز": "bread, to bake", "خبو": "to subside, to die down, dim", "ختر": "to betray, treacherous", "خرطم": "a snout, a nose, a trunk", "خشب": "wood, timber, logs", "خضد": "to cut, thornless, trimmed", "خطط": "to draw a line, a mark, a plan", "خلع": "to remove, to take off, to strip", "خمط": "bitter fruit, a sour tree", "خنق": "to strangle, to choke, strangled", "خيم": "a tent, tents, a pavilion", "دثر": "to wrap up, a cloak, a garment", "درهم": "a dirham, silver coins", "دسر": "nails, planks, ribs (of a ship)", "دسو": "to hide, to corrupt, to conceal", "دفأ": "warmth, to warm", "دفق": "to gush, to pour forth, gushing", "دمدم": "to destroy completely, to level", "دمغ": "to crush, to smash, to prevail over", "دنر": "a dinar, gold coins", "دهق": "overflowing, brimful, abundant", "دهم": "to be dark, very dark, black-green", "دهي": "to be cunning, shrewdness, calamity", "ذأم": "to blame, to condemn, disgraced", "ذبذب": "to waver, to vacillate, fluctuating", "ذخر": "to store, to save, a reserve", "ذعن": "to submit, to be obedient, compliance", "ذكو": "to be pure, to sacrifice properly", "ذهل": "to be stunned, to forget, distracted", "ذود": "to drive away, to defend, a few camels", "ذيع": "to spread, to disseminate", "رحق": "sealed nectar, pure wine", "رخو": "to be soft, to be loose, soft", "ردم": "to fill up, a barrier, a dam", "رصص": "to arrange in rows, to set firmly, lead (metal)", "رغم": "to compel, despite, dust on the nose", "رفرف": "a cushion, a green garment, canopy", "رقق": "to be thin, parchment, fine", "رمح": "a spear, a lance", "رمد": "ash, ashes, hot ashes", "رمز": "to signal, a sign, a gesture", "رهو": "to be calm, calm water, at ease", "روع": "to frighten, fear, the mind", "ريش": "feathers, plumage, clothing", "ريع": "a height, elevated, a tower", "زبن": "to push, to thrust, a guard of hell", "زرب": "an enclosure, a pen, gold", "زرق": "blue, to pierce, to throw", "زري": "to despise, to belittle, contemptible", "زفف": "to hasten, to rush, a group", "زمل": "to wrap, to enwrap, a garment", "زمهر": "intense cold, a fierce gaze, bitter cold", "زنجبل": "ginger", "زنم": "to mark, branded, base, ignoble", "سجو": "to cover, to be still, calm night", "سحل": "a garment, a cloth, to drag", "سدي": "to let loose, to neglect, abandoned", "سرد": "to link, to stitch, chain mail", "سردق": "a pavilion, a tent, an enclosure", "سطو": "to assault, to attack, to overpower", "سغب": "to be hungry, hunger, famine", "سفع": "to seize, to drag, the forelock", "سلق": "to lash with the tongue, to scold", "سمد": "to sing, to be heedless, amusement", "سمك": "to raise, to elevate, a ceiling", "سنم": "a spring in paradise, exalted", "سنه": "to change, unchanged (water)", "سهر": "to stay awake, Sirius (star)", "سهل": "to be easy, a plain, level ground", "سهم": "an arrow, a share, a lot", "سوح": "a courtyard, an open space", "سوط": "a whip, a lash, to mix", "سيب": "to flow, to let go, a stream", "شتو": "winter, the cold season", "شحم": "fat, grease", "شرد": "to scatter, to drive away, to flee", "شرذم": "a small group, a band, remnants", "شرط": "to condition, a sign, a stipulation", "شعل": "to kindle, a flame, white-haired", "شغف": "to captivate, intense love, passion", "شفه": "a lip, lips", "شكس": "to be quarrelsome, difficult, partners", "شمت": "to gloat, to rejoice at misfortune", "شمخ": "to be lofty, towering, high", "شمز": "to shrink, to recoil, to detest", "شوب": "to mix, a mixture, a drink", "شوظ": "a flame, a blaze of fire", "شوك": "thorns, spines, power", "صخخ": "a loud cry, a blast, deafening", "صرع": "to throw down, to knock down", "صعر": "to turn away (the cheek), pride", "صفصف": "a level plain, flat land", "صفن": "a hoof, hooves (of horses)", "صكك": "to strike, to slap, to hit", "صلد": "to be hard, barren rock, smooth", "صمع": "a hermitage, a place of worship", "صوع": "a cup, a drinking vessel, a measure", "صيص": "a fortress, a stronghold, towers", "صيف": "summer, the hot season", "ضأن": "sheep, ewes", "ضبح": "to pant, to snort (horses)", "ضدد": "an adversary, an opponent, against", "ضفدع": "frogs", "ضمر": "to be lean, emaciated, distant", "ضنك": "to be narrow, distress, hardship", "ضنن": "to be miserly, to withhold, stingy", "ضهأ": "to resemble, to imitate", "ضير": "to harm, harm, damage", "ضيز": "to be unjust, unfair, biased", "طحو": "to spread out, to flatten", "طفف": "to give short measure, to cheat", "طلح": "banana trees, acacia, a thorny tree", "طلل": "remains, a ruin, dew", "طمم": "to overflow, to bury, to cover", "طود": "a mountain, a great mountain", "ظعن": "to depart, to travel, a journey", "عبقر": "fine carpets, a lush garden", "عدس": "lentils", "عرجن": "a dry date stalk, a curved branch", "عرم": "a dam, a flood, to be strong", "عزو": "to attribute, to claim, a group", "عسعس": "to darken, to draw near (night)", "عضو": "a member, a limb, a part", "عفر": "dust, an ifrit (powerful jinn)", "عمق": "to be deep, depth, a distant place", "عنو": "to be humble, to submit, humbled", "عوق": "to hinder, to delay, to hold back", "عول": "to cry, to deviate, to be unjust", "عيب": "a fault, a defect, a flaw", "غبن": "to cheat, to be deceived, mutual loss", "غدق": "abundant water, plentiful", "غزو": "to raid, a military expedition, war", "غصب": "to seize, to usurp, by force", "غصص": "to choke, a choking, stuck in throat", "غطش": "to be dark, darkness (of night)", "غمز": "to wink, to gesture, to defame", "غمض": "to close (eyes), to overlook, inferior", "فتأ": "to cease, to stop, continually", "فجو": "an opening, a gap, a cave", "فرث": "intestinal contents, dung, filth", "فره": "to be skilled, lively, joyful", "فسر": "to explain, to interpret, explanation", "فصح": "to be clear, eloquent, to express", "فصم": "to break, to shatter, to sever", "فضح": "to expose, to disgrace, shame", "فضو": "to be wide, spacious, open", "فظظ": "to be harsh, rude, rough-spoken", "فقع": "to be bright yellow, intense yellow", "فلن": "so-and-so, such a person", "فنن": "branches, kinds, varieties", "فني": "to perish, to be consumed, annihilation", "فوض": "to entrust, to delegate, to submit", "فوم": "wheat, grain, garlic", "فيل": "an elephant, elephants", "قبح": "to be ugly, ugliness, disgrace", "قثأ": "cucumbers", "قدح": "to strike fire, a cup, a bowl", "قسر": "to compel, to force, coercion", "قسس": "a priest, clergy, religious leaders", "قصف": "to break, to destroy, a storm", "قصم": "to break, to crush, to destroy", "قضب": "vegetables, clover, fodder", "قضض": "to burst, to demolish, to break", "قطط": "short, curly (hair), a piece", "قطمر": "a thin membrane, a speck, nothing", "قعر": "the bottom, the depth, the base", "قفل": "a lock, to lock, to return", "قلع": "to uproot, to pull out, to extract", "قمح": "to raise the head, proud, wheat", "قمطر": "severe, a harsh day, frowning", "قمع": "to suppress, to subdue, to restrain", "قمل": "lice", "قنو": "a cluster (of dates), a bunch", "قني": "to acquire, to save, to possess", "قوب": "to hollow out, a chick, an egg", "كبد": "a liver, hardship, toil", "كبكب": "to throw down, to cast headlong", "كثب": "near, close, heaped up", "كدر": "to be turbid, murky, to be scattered", "كدي": "to be stingy, to be hard, barren", "كسد": "to be stagnant, unsaleable, sluggish", "كشط": "to peel off, to strip, to remove", "كفت": "to gather, to contain, sufficient", "كلأ": "to guard, to preserve, herbage", "كلح": "to frown, to scowl, grim-faced", "كند": "to be ungrateful, to deny blessings", "كنس": "to sweep, to conceal, retreating stars", "كوي": "to brand, to burn, cauterize", "لحف": "to press, to insist, to wrap", "لحن": "a tone, to hint, to understand", "لحي": "a jaw, a jawbone, a beard", "لزب": "to stick, dry clay, firm", "لظي": "a blazing fire, hellfire, flames", "لفح": "to burn, to scorch, to blast", "لفظ": "to utter, to speak, a word", "لقب": "a title, a nickname, to give a name", "لقح": "to pollinate, to fertilize, winds", "لهم": "to inspire, to swallow, inspiration", "لوت": "Lut, a prophet", "لوذ": "to shelter, to take refuge behind", "ليت": "if only, would that, wish", "محل": "a place, a station, a destination", "مخض": "to churn, labor pains, to shake", "مرت": "barren, smooth, hairless", "مرو": "Marwah (a hill), a stone", "مزن": "rain clouds, a cloud", "مسو": "to touch, evening, to become", "مشج": "to mix, mixed fluids, a mixture", "مطو": "to stretch, to extend, to prolong", "معز": "goats", "معي": "intestines, bowels, guts", "مكك": "Makkah", "مكل": "a measure, a full measure", "مكو": "to whistle, to clap, whistling", "مير": "to provide, provisions, supplies", "نبز": "to call by a bad name, a nickname", "نبط": "to dig, to extract, to bring forth", "نجد": "a high land, Najd, to help", "نحب": "a vow, to die, a term, fate", "نخر": "to decay, decayed bones, hollow", "نسر": "an eagle, a vulture, Nasr (idol)", "نضخ": "to gush, to overflow, springing", "نطح": "to butt, to gore, to strike", "نعل": "a shoe, sandals, footwear", "نغض": "to shake (the head), to nod", "نفث": "to blow, to spit, witchcraft", "نفح": "to blow, a breath, a puff", "نفي": "to deny, to exile, to reject", "نقع": "to soak, dust, to quench", "نكد": "to be difficult, stingy, scanty", "نمرق": "a cushion, a pillow", "نمم": "to gossip, tale-bearing, slander", "نوأ": "to be heavy, a burden, a key", "نوش": "to reach, to attain, to seize", "نوص": "to flee, to escape, a refuge", "نون": "a fish, a whale, the letter nun", "هاء": "to give, take, here", "هجد": "to sleep, to pray at night, vigil", "هجع": "to sleep, to rest, a portion of night", "هدهد": "a hoopoe (bird)", "هرب": "to flee, to escape, flight", "هرت": "Harut (an angel)", "هزل": "to be thin, to joke, jesting", "هشش": "to drive (sheep), to be brittle, dry", "هلع": "to be impatient, anxiety, greed", "همد": "to subside, to be extinct, dead", "همر": "to pour, to flow, gushing", "همس": "to whisper, a whisper, footsteps", "هيت": "come here, an invitation", "هيل": "to pour, to scatter, flowing sand", "وأد": "to bury alive, female infanticide", "وأل": "a refuge, a shelter, to flee", "وبر": "hair, fur, animal hair", "وتن": "a jugular vein, a lifeline", "وسن": "to be drowsy, sleep, drowsiness", "وضن": "to weave, woven, interlaced", "وطن": "a homeland, a place, to settle", "وفد": "a delegation, a group of visitors", "وفر": "to be abundant, plentiful, full", "وفض": "to hasten, to run, groups", "وقب": "to enter, to set (night), darkness", "وقذ": "to strike dead, killed by a blow", "وكد": "to confirm, to affirm, to strengthen", "وكز": "to punch, to strike with fist", "وني": "to be weak, to flag, to slacken", "وهج": "to glow, blazing, a burning lamp", "وهي": "to be weak, to collapse, frail", "يقظ": "to be awake, vigilant, alert", "ينع": "to ripen, ripe, mature", } def main(): conn = _uslap_connect(DB_PATH) if _HAS_WRAPPER else sqlite3.connect(DB_PATH) conn.execute("PRAGMA foreign_keys = ON") # Delete DEPRECATED entries deprecated = conn.execute( "SELECT root_id, root_unhyphenated FROM quran_root_dictionary WHERE root_unhyphenated LIKE 'DEPRECATED%'" ).fetchall() for d in deprecated: print(f"Deleting deprecated entry: {d[0]} — {d[1]}") conn.execute("DELETE FROM quran_root_dictionary WHERE root_id=?", (d[0],)) updated = 0 for root, meaning in FINAL_ROOTS.items(): row = conn.execute( "SELECT root_meaning FROM quran_root_dictionary WHERE root_unhyphenated=?", (root,) ).fetchone() if row and row[0] is None: conn.execute( "UPDATE quran_root_dictionary SET root_meaning=? WHERE root_unhyphenated=?", (meaning, root) ) updated += 1 conn.commit() after = conn.execute( "SELECT COUNT(*) FROM quran_root_dictionary WHERE root_meaning IS NULL" ).fetchone()[0] total = conn.execute("SELECT COUNT(*) FROM quran_root_dictionary").fetchone()[0] print(f"\nFinal batch updated: {updated}") print(f"NULL remaining: {after} / {total}") print(f"Populated: {total - after} ({(total - after) / total * 100:.1f}%)") # Word-level coverage check using correct column name word_covered = conn.execute(""" SELECT COUNT(*) FROM quran_word_roots w JOIN quran_root_dictionary d ON w.root = d.root_unhyphenated WHERE d.root_meaning IS NOT NULL AND w.root IS NOT NULL """).fetchone()[0] total_rooted = conn.execute( "SELECT COUNT(*) FROM quran_word_roots WHERE root IS NOT NULL" ).fetchone()[0] total_words = conn.execute("SELECT COUNT(*) FROM quran_word_roots").fetchone()[0] print(f"\nWord-level coverage:") print(f" Rooted words with meanings: {word_covered}/{total_rooted} ({word_covered / total_rooted * 100:.1f}%)") print(f" Overall: {word_covered}/{total_words} ({word_covered / total_words * 100:.1f}%)") conn.close() if __name__ == "__main__": main()