Spaces:
Sleeping
Sleeping
| #!/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() | |