{"id":20912445,"url":"https://github.com/fogleman/twl06","last_synced_at":"2025-05-13T08:30:51.144Z","repository":{"id":11423849,"uuid":"13875886","full_name":"fogleman/TWL06","owner":"fogleman","description":"Official Scrabble dictionary packaged into a convenient Python module.","archived":false,"fork":false,"pushed_at":"2015-08-02T10:25:57.000Z","size":464,"stargazers_count":43,"open_issues_count":2,"forks_count":16,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-01T20:12:26.159Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fogleman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-10-26T01:33:18.000Z","updated_at":"2025-01-29T08:49:54.000Z","dependencies_parsed_at":"2022-08-25T19:20:43.544Z","dependency_job_id":null,"html_url":"https://github.com/fogleman/TWL06","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fogleman%2FTWL06","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fogleman%2FTWL06/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fogleman%2FTWL06/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fogleman%2FTWL06/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fogleman","download_url":"https://codeload.github.com/fogleman/TWL06/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253903605,"owners_count":21981726,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-18T14:27:22.804Z","updated_at":"2025-05-13T08:30:50.890Z","avatar_url":"https://github.com/fogleman.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## TWL06: The Official Scrabble Dictionary\n\nA convenient, self-contained, 515 KB Scrabble dictionary module, ideal\nfor use in word games.\n\nFunctionality:\n\n* Check if a word is in the dictionary.\n* Enumerate all words in the dictionary.\n* Determine what letters may appear after a given prefix.\n* Determine what words can be formed by anagramming a set of letters.\n\nSample usage:\n\n    \u003e\u003e\u003e import twl\n    \u003e\u003e\u003e twl.check('dog')\n    True\n    \u003e\u003e\u003e twl.check('dgo')\n    False\n    \u003e\u003e\u003e words = set(twl.iterator())\n    \u003e\u003e\u003e len(words)\n    178691\n    \u003e\u003e\u003e twl.children('dude')\n    ['$', 'd', 'e', 's']\n    \u003e\u003e\u003e list(twl.anagram('top'))\n    ['op', 'opt', 'pot', 'to', 'top']\n\nProvides a simple API using the TWL06 (official Scrabble tournament) \ndictionary. Contains American English words that are between 2 and 15 \ncharacters long, inclusive. The dictionary contains 178691 words.\n\nImplemented using a DAWG (Directed Acyclic Word Graph) packed in a \nbinary lookup table for a very small memory footprint, not only on \ndisk but also once loaded into RAM. In fact, this is the primary\nbenefit of this method over others - it is optimized for low memory\nusage (not speed).\n\nThe data is stored in the Python module as a base-64 encoded, \nzlib-compressed string.\n\nEach record of the DAWG table is packed into a 32-bit integer.\n\n    MLLLLLLL IIIIIIII IIIIIIII IIIIIIII\n\n* M - More Flag\n* L - ASCII Letter (lowercase or '$')\n* I - Index (Pointer)\n\nThe helper method `_get_record(index)` will extract these three elements \ninto a Python tuple such as `(True, 'a', 26)`.\n\nAll searches start at index 0 in the lookup table. Records are scanned \nsequentially as long as the More flag is set. These records represent all \nof the children of the current node in the DAWG. For example, the first\n26 records are:\n\n    0 (True, 'a', 26)\n    1 (True, 'b', 25784)\n    2 (True, 'c', 11666)\n    3 (True, 'd', 39216)\n    4 (True, 'e', 33704)\n    5 (True, 'f', 50988)\n    6 (True, 'g', 46575)\n    7 (True, 'h', 60884)\n    8 (True, 'i', 56044)\n    9 (True, 'j', 67454)\n    10 (True, 'k', 65987)\n    11 (True, 'l', 76093)\n    12 (True, 'm', 68502)\n    13 (True, 'n', 83951)\n    14 (True, 'o', 79807)\n    15 (True, 'p', 89048)\n    16 (True, 'q', 88465)\n    17 (True, 'r', 113967)\n    18 (True, 's', 100429)\n    19 (True, 't', 125171)\n    20 (True, 'u', 119997)\n    21 (True, 'v', 134127)\n    22 (True, 'w', 131549)\n    23 (True, 'x', 136449)\n    24 (True, 'y', 136058)\n    25 (False, 'z', 136584)\n\nThe root node contains 26 children because there are words that start \nwith all 26 letters. Other nodes will have fewer children. For example,\nif we jump to the node for the prefix 'b', we see:\n\n    25784 (True, 'a', 25795)\n    25785 (True, 'd', 28639)\n    25786 (True, 'e', 27322)\n    25787 (True, 'h', 29858)\n    25788 (True, 'i', 28641)\n    25789 (True, 'l', 29876)\n    25790 (True, 'o', 30623)\n    25791 (True, 'r', 31730)\n    25792 (True, 'u', 32759)\n    25793 (True, 'w', 33653)\n    25794 (False, 'y', 33654)\n\nSo the prefix 'b' may be followed only by these letters:\n\n    a, d, e, h, i, l, o, r, u, w, y\n\nThe helper method `_get_child(index, letter)` will return a new index\n(or `None` if not found) when traversing an edge to a new node. For\nexample, `_get_child(0, 'b')` returns 25784.\n\nThe search is performed iteratively until the sentinel value, $, is\nfound. If this value is found, the string is a word in the dictionary.\nIf at any point during the search the appropriate child is not found,\nthe search fails - the string is not a word.\n\nSee also:\n\n* http://code.activestate.com/recipes/577835-self-contained-twl06-dictionary-module-500-kb/\n* http://en.wikipedia.org/wiki/Official_Tournament_and_Club_Word_List\n* http://www.isc.ro/lists/twl06.zip\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffogleman%2Ftwl06","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffogleman%2Ftwl06","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffogleman%2Ftwl06/lists"}