uslap-query / Code_files /archive /populate_final_roots.py
uslap's picture
Upload folder using huggingface_hub
7cc8e29 verified
Raw
History Blame Contribute Delete
18.1 kB
#!/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()