{"id":35239598,"url":"https://github.com/btfranklin/wordsmith-engine","last_synced_at":"2026-02-17T04:03:21.943Z","repository":{"id":330940921,"uuid":"1124521321","full_name":"btfranklin/wordsmith-engine","owner":"btfranklin","description":"Composable, deterministic-friendly text-generation components for Python","archived":false,"fork":false,"pushed_at":"2026-01-09T02:48:39.000Z","size":538,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-12T17:16:00.083Z","etag":null,"topics":["computational-creativity","generative-text","procedural-generation","text-generation"],"latest_commit_sha":null,"homepage":"","language":"Python","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/btfranklin.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,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2025-12-29T06:51:26.000Z","updated_at":"2026-01-09T02:41:09.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/btfranklin/wordsmith-engine","commit_stats":null,"previous_names":["btfranklin/wordsmith-engine"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/btfranklin/wordsmith-engine","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/btfranklin%2Fwordsmith-engine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/btfranklin%2Fwordsmith-engine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/btfranklin%2Fwordsmith-engine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/btfranklin%2Fwordsmith-engine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/btfranklin","download_url":"https://codeload.github.com/btfranklin/wordsmith-engine/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/btfranklin%2Fwordsmith-engine/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29532968,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-17T03:01:11.216Z","status":"ssl_error","status_checked_at":"2026-02-17T03:00:31.803Z","response_time":100,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["computational-creativity","generative-text","procedural-generation","text-generation"],"created_at":"2025-12-30T04:43:01.859Z","updated_at":"2026-02-17T04:03:21.905Z","avatar_url":"https://github.com/btfranklin.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# The Wordsmith Engine\n\n![Wordsmith Engine banner](https://raw.githubusercontent.com/btfranklin/wordsmith-engine/main/.github/social%20preview/wordsmith_engine_social_preview.jpg \"The Wordsmith Engine\")\n\n[![Build Status](https://github.com/btfranklin/wordsmith-engine/actions/workflows/python-package.yml/badge.svg)](https://github.com/btfranklin/wordsmith-engine/actions/workflows/python-package.yml) [![Supports Python versions 3.12+](https://img.shields.io/pypi/pyversions/wordsmith-engine.svg)](https://pypi.python.org/pypi/wordsmith-engine)\n\nThe Wordsmith Engine is a composable, deterministic-friendly text-generation toolkit for Python.\nIt started as a port of the Swift package [`Wordsmith`](https://github.com/btfranklin/wordsmith)\n(by the same author) and focuses on building\nrich, varied text with small, reusable components.\n\n## What it is for\n- Generating names for people, towns, ships, gangs, and creative works.\n- Building simple language generators from reusable parts.\n- Producing repeatable output with a seeded RNG.\n\n## Installation\nUse PDM to install dependencies for development:\n```bash\npdm install --group dev\n```\n\n## Quickstart\n```python\nfrom wordsmith import WorkTitle\n\nprint(WorkTitle()())\n```\n\n## Core concepts\nThe Wordsmith Engine is centered around the `Component` type. Each component can render text\nwith a provided random number generator.\n\nOperator DSL (preferred):\n- `left | right`: Join components with a space.\n- `left + right`: Join components with no separator (useful for punctuation).\n\nKey combinators:\n- `text(*parts, sep=\"\")`: Join components with a custom separator.\n- `one_of(*options)`: Pick a random option.\n- `weighted_one_of((weight, option), ...)`: Weighted choice across many options.\n- `either(a, b, first_probability=0.5)`: Weighted choice between two options.\n- `maybe(*parts, probability=0.5)`: Optionally include text.\n\nCommon decorators on components:\n- `.title_case()` for title casing (with small-word rules).\n- `.capitalized()` to capitalize all words.\n- `.first_upper()` for first-letter capitalization.\n- `.prefixed_by_article()` / `.prefixed_by_determiner()` for grammar helpers.\n- `.possessive_form()` for possessives.\n\n## Usage examples\n```python\nimport random\n\nfrom wordsmith import Adjective, Noun, WorkTitle, either, maybe, one_of\n\nrng = random.Random(42)\n\ntitle = (\n    \"The\"\n    | maybe(Adjective())\n    | one_of(\"Journey\", \"Voyage\", \"Chronicles\")\n    | \"of\"\n    | Noun().prefixed_by_article()\n).title_case()\n\nline = (\"Once\" | maybe(\"upon a time\", probability=0.5)) + \".\"\n\nprint(title(rng))\nprint(line(rng))\nprint(WorkTitle()(rng))\n```\n\n## Generators included\nThe Wordsmith Engine ships with a growing set of generators:\n- Names: `GivenName`, `Surname`, `PersonName`, `WeirdName`, `AncientName`\n- Locations: `TownName`\n- Groups: `CriminalGangName`, `BandName`\n- Vessels: `NauticalShipName`\n- Works: `SimpleWorkTitle`, `UnusualWorkTitle`, `WorkTitle`\n- Materials: `FictionalElementName`, `FictionalMineralName`, `ChemicalCompoundName`\n- Specials: `ReadableUniqueIdentifier`, `ExoticCharacter`\n\n## Deterministic output\nAll components accept a `random.Random` instance. If you want repeatable results,\npass a seeded RNG.\n```python\nimport random\nfrom wordsmith import WorkTitle\n\nrng = random.Random(1234)\nprint(WorkTitle()(rng))\nprint(WorkTitle()(rng))\n```\n\n## Examples\nRun any script under `examples/` with PDM, for example:\n```bash\npdm run python examples/work_titles.py\n```\n\n## Development\n- Install: `pdm install --group dev`\n- Run tests: `pdm run pytest`\n- Run lint: `pdm run lint`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbtfranklin%2Fwordsmith-engine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbtfranklin%2Fwordsmith-engine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbtfranklin%2Fwordsmith-engine/lists"}