{"id":20560846,"url":"https://github.com/tinmarr/word_unscrambler","last_synced_at":"2025-04-14T14:06:37.703Z","repository":{"id":81412661,"uuid":"131459026","full_name":"tinmarr/word_unscrambler","owner":"tinmarr","description":"This rust program outputs a list of the possible options a scrambled word could be.","archived":false,"fork":false,"pushed_at":"2024-10-04T02:12:30.000Z","size":952,"stargazers_count":28,"open_issues_count":0,"forks_count":17,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-28T03:05:56.900Z","etag":null,"topics":["python","rust","unscrambler","word-unscrambler"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tinmarr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-04-29T02:10:08.000Z","updated_at":"2024-12-30T22:23:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"ae508a91-db50-4e32-abc7-6a67f0602fa9","html_url":"https://github.com/tinmarr/word_unscrambler","commit_stats":null,"previous_names":["tinmarr/word-unscrambler"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinmarr%2Fword_unscrambler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinmarr%2Fword_unscrambler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinmarr%2Fword_unscrambler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinmarr%2Fword_unscrambler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tinmarr","download_url":"https://codeload.github.com/tinmarr/word_unscrambler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248894936,"owners_count":21179152,"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":["python","rust","unscrambler","word-unscrambler"],"created_at":"2024-11-16T03:56:07.595Z","updated_at":"2025-04-14T14:06:37.650Z","avatar_url":"https://github.com/tinmarr.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# word_unscrambler\n\nThis Rust program outputs a list of the possible options a scrambled word could be.\n\n_Looking for the Python version? Its in the\n[python-version](https://github.com/tinmarr/Word-Unscrambler/tree/python-version) branch_\n\n_Looking for the Go version? Its in he\n[go-version](https://github.com/tinmarr/Word-Unscrambler/tree/go-version) branch_\n\n![Demo Gif](demo_files/demo.gif)\n\n## About\n\nThis program was created by [Martin Chaperot-Merino](https://github.com/tinmarr)\n\nThis word unscrambler can clean unstructured text before employing a named entities recognition (NER) algorithm. For\nexample, the word unscrambler function can be applied to every word in a text file before looking these words up in a\ngazetteer (a list of entities such as cities, organizations, days of the week, etc.)\n\n# How to use\n\n1. Clone the repo\n2. Run `cargo run`\n3. Enter a scrambled word\n4. Hit enter\n\n# How it works\n\nIt takes words from a text file and uses a lookup function to find words with the same letters (where the order of words\ndoes not matter).\n\n## The key to its speed\n\nIt converts all the words into integers (which is based on the letters) and groups words with the same integer in a\n`BTreeMap`. This is a hash map that uses a binary search tree instead of a hashing algorithm (faster for integers). Then\nit converts the typed word into an integer and looks up that integer in the map.\n\nThe function `word_2_int` (shown below) is what converts the word to an unsigned 128 bit integer. Every 4 bits\nrepresents the number of occurrences of a specific letter. For example, the string \"aaabc\" would be represented by 0000\n... 0001 0001 0011 or 275. The beauty of this system is that all words with those same letters will be represented by\nthat same number. This allows us to use that number as the key for our map.\n\n```rust\nconst LETTERS: [char; 26] = [\n    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',\n    't', 'u', 'v', 'w', 'x', 'y', 'z',\n];\n\nfn word_2_int(word: \u0026String) -\u003e u128 {\n    let mut word_int: u128 = 0;\n    for letter in word.chars() {\n        let i: u32 = match LETTERS.binary_search(\u0026letter) {\n            Ok(i) =\u003e i,\n            Err(_) =\u003e continue,\n        }\n        .try_into()\n        .expect(\"If this panics something went horribly wrong\");\n        word_int += 2u128.pow(4u32 * i);\n    }\n    word_int\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinmarr%2Fword_unscrambler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftinmarr%2Fword_unscrambler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinmarr%2Fword_unscrambler/lists"}