{"id":29066958,"url":"https://github.com/exogen/snacklish","last_synced_at":"2025-06-27T10:09:41.809Z","repository":{"id":301182966,"uuid":"1001742438","full_name":"exogen/snacklish","owner":"exogen","description":"Snacklish, now with improved flavor","archived":false,"fork":false,"pushed_at":"2025-06-25T15:37:20.000Z","size":1727,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-25T15:43:31.427Z","etag":null,"topics":["snacklish","snickers","translator"],"latest_commit_sha":null,"homepage":"https://exogen.github.io/snacklish/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/exogen.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"exogen","buy_me_a_coffee":"mosswood"}},"created_at":"2025-06-13T23:45:40.000Z","updated_at":"2025-06-25T15:37:24.000Z","dependencies_parsed_at":"2025-06-25T15:43:35.629Z","dependency_job_id":"910dcef8-e5f2-4bb9-aefc-59feb689e800","html_url":"https://github.com/exogen/snacklish","commit_stats":null,"previous_names":["exogen/snacklish"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/exogen/snacklish","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exogen%2Fsnacklish","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exogen%2Fsnacklish/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exogen%2Fsnacklish/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exogen%2Fsnacklish/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/exogen","download_url":"https://codeload.github.com/exogen/snacklish/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exogen%2Fsnacklish/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262235803,"owners_count":23279570,"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":["snacklish","snickers","translator"],"created_at":"2025-06-27T10:09:40.402Z","updated_at":"2025-06-27T10:09:41.800Z","avatar_url":"https://github.com/exogen.png","language":"TypeScript","funding_links":["https://github.com/sponsors/exogen","https://buymeacoffee.com/mosswood"],"categories":[],"sub_categories":[],"readme":"\u003ca href=\"https://exogen.github.io/snacklish/\"\u003e\u003cimg src=\"snacklish.png\" alt=\"Snacklish: Improved Flavor\"\u003e\u003c/a\u003e\n\n# Snacklish\n\n**Now with improved flavor!** [Check out the demo site](https://exogen.github.io/snacklish/)\nto handle your flavoryday translation needs.\n\n## Introduction\n\nSnacklish is a delicious language invented for Snickers based on snack-related\nwordplay. This library and demo site were created to put English-to-Snacklish\ntranslations back into the mouths of the people.\n\nIf you just want to have some quick fun, [use the demo site!](https://exogen.github.io/snacklish/)\n\nFor your delectabusiness and enuterprise Snacklish needs, you’ll of chocourse want\nto caramakel use of [thelicious library](#installation) directly.\n\n## Why?\n\nTo prevent Snacklish from becrumbing a fed language, of course. The original Snacklish\ntranslator has been offline for far chew long. Some attempts were made to chompy\nit, but nuttin that I found snackceptable.\n\n## Improvements\n\nImproved flavor, you say? [Chew you havisfaction a singlelicious satisfact to snack that up?](https://www.youtube.com/watch?v=hNUNx319UCM)\n\n- 🆕 New words have been added to the lexicon, like **crave**, **cream**, **crumb**,\n  and **melt**.\n- 💎 Updated pattern matching to prefer better substitutions.\n- 🥴 Some of the linguistically and phonetically questionable choices have been\n  removed completely, like little \u0026rarr; snackittle, there \u0026rarr; treatere, yes\n  \u0026rarr; yumye, and more.\n- 🎲 Randomization is customizable, so you can dial down repetitive output, control\n  the chances of substitution based on word frequency, or use a custom algorithm.\n\n## How?\n\nTranslation is based on simple pattern-based substitution rules. Automatic phonetic\nmatching is not attempted. Check out the rules in [snacklish.txt](./src/snacklish.txt).\n\n## Installation\n\n```console\nnpm install snacklish\n```\n\n## Usage\n\n```ts\nimport { createTranslator } from \"snacklish\";\n\nconst translate = await createTranslator();\n\ntranslate(\"hello, world!\");\n// -\u003e \"caramello, chocoworld!\"\n```\n\n## API\n\n### createTranslator\n\nReturn a function that can be used to translate a text document from English to\nSnacklish.\n\n```ts\ncreateTranslator(options: {\n  getRandom: () =\u003e number;\n  getProbability: ProbabilityFunction;\n}): Promise\u003cTranslatorFunction\u003e\n```\n\n### loadRules\n\nLoad and parse the default Snacklish ruleset. The result is a ruleset that can\nbe used with [rulesToFunction](#rulesToFunction).\n\n```ts\nloadRules(): Promise\u003cRuleSet\u003e\n```\n\n### loadRuleString\n\nLoad the default Snacklish document as a string from [snacklish.txt](./src/snacklish.txt).\n\n```ts\nloadRuleString(): Promise\u003cstring\u003e\n```\n\n### parseRules\n\nParse a string containing substitution rules.\n\n```ts\nparseRules(ruleString: string): RuleSet\n```\n\n### rulesToFunction\n\nTurn a parsed ruleset into a function that translates a single token at a time.\nTo translate a document using this function, you will need to call it for each\ntoken and join the results.\n\n```ts\nrulesToFunction(\n  rules: RuleSet;\n  options: {\n    getRandom: () =\u003e number;\n    getProbability: (token: string) =\u003e number;\n  }\n): (token: string) =\u003e string\n```\n\n### tokenize\n\nSplit a text document into tokens using the default tokenizer.\n\n```ts\ntokenize(text: string): string[]\n```\n\n### Custom Random Source\n\nThe `getRandom` option can be used to provide a custom random source (for example,\nto supply a seeded PRNG). The default is `Math.random()`.\n\n### Probability Functions\n\nTo customize the frequency of substitutions, you may pass a custom “probability\nfunction.” The function will be passed the original token, and must return a\nnumber. If the result of `Math.random()` is less than the number, the token is\nreplaced. For example, a function that always returns 1 will always substitute;\none that returns 0 will never substitute.\n\nThe following exports are included with the library to create probability\nfunctions.\n\n#### getZeroProbabilityFunction\n\nNever substitute.\n\n#### getKindaProbabilityFunction\n\nSubstitute sometimes. Shorter patterns are less likely to be substituted, longer\nwords are more likely.\n\n#### getNormalProbabilityFunction\n\nSubstitute sometimes. Shorter patterns are less likely to be substituted, longer\nwords are more likely.\n\n#### getExtremeProbabilityFunction\n\nAlways substitute.\n\n## Disclaimer\n\nThis is a fan project and has no affiliation with Snickers, Mars Inc., or TBWA\nNY.\n\nSnickers is a registered trademark of Mars Inc.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexogen%2Fsnacklish","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexogen%2Fsnacklish","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexogen%2Fsnacklish/lists"}