greenideas


Namegreenideas JSON
Version 0.6.1 PyPI version JSON
download
home_pageNone
SummaryA package to generate grammatically valid but semantically nonsensical English sentences.
upload_time2025-08-23 07:54:19
maintainerNone
docs_urlNone
authorChris Hengler
requires_python>=3.11
licenseMIT
keywords grammar procedural generation sentence generation placeholder text twaddle
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Python application](https://github.com/chrishengler/greenideas/actions/workflows/python-app.yml/badge.svg)](https://github.com/chrishengler/greenideas/actions/workflows/python-app.yml)

# Green Ideas

Green Ideas is a Python package designed to generate grammatically valid but semantically nonsensical sentences. It is effectively a generative grammar engine, employing recursive rewrite rules to create sentence structures. It can then convert these structures into templates compatible with the `twaddle` package for language templating.

## Features

Greenideas defines a grammar engine which expands a root sentence node into a full sentence
tree, according to a variety of user-defined rules. Documentation for defining these rules will come at a later date. The package includes a pre-written set of rules which produce (mostly) grammatically valid English sentences. 

The key features of the package are:

- Generation of trees describing valid English sentence structures
- Support for recursive rewrite rules for sentence structure generation.
- Converting sentence trees into twaddle-compatible templates.
- Modular design allowing for easy extension and modification of grammar rules.

## Installation

The package can be downloaded manually from Github or installed via pip:

```bash
pip install greenideas
```

The package uses Poetry for dependency management, dependencies can be installed by running

```bash
poetry install
```

## Usage

To use the `greenideas` package, you can (or at least you will be able to, at some point) import the main classes from the package, provide the location of your twaddle dictionaries, and start generating sentences. The __main__.py file offers a simple example:

```python
import readline  # noqa: F401
import sys

from twaddle.runner import TwaddleRunner

from greenideas.grammar_engine import GrammarEngine
from greenideas.parts_of_speech.pos_types import POSType
from greenideas.rules.default_english_rules.default_rules import default_rules
from greenideas.twaddle.default_formatters.default_formatting_handlers import (
    default_formatting_handlers,
)
from greenideas.twaddle.twaddle_formatter import TwaddleFormatter


def main():
    if len(sys.argv) < 2:
        print("argument required: path to directory containing dictionary files")
        return
    dictionary_path = sys.argv[1]
    twaddle_runner = TwaddleRunner(dictionary_path)

    engine = GrammarEngine()
    engine.add_ruleset(default_rules)
    tree = engine.generate_tree(POSType.S)
    print(tree)

    formatter = TwaddleFormatter()
    for type, handler in default_formatting_handlers.items():
        formatter.register_formatting_handler(type, handler)

    twaddle_string = formatter.format_as_sentence(tree)
    print(twaddle_string)
    print(twaddle_runner.run_sentence(twaddle_string))
```

An official set of twaddle dictionaries for use with the default English language rules is
available at https://github.com/chrishengler/greenideas-dict

## Contributing

Contributions are welcome! Please feel free to submit a pull request or open an issue for any enhancements or bug fixes.

## License

This project is licensed under the MIT License. See the LICENSE file for more details.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "greenideas",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": null,
    "keywords": "grammar, procedural generation, sentence generation, placeholder text, twaddle",
    "author": "Chris Hengler",
    "author_email": "chrysics@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/b5/2f/e5cf2e16a61c1c4531b37a9dc96b43913ddaa090621db2edb1d3a7e2b2ec/greenideas-0.6.1.tar.gz",
    "platform": null,
    "description": "[![Python application](https://github.com/chrishengler/greenideas/actions/workflows/python-app.yml/badge.svg)](https://github.com/chrishengler/greenideas/actions/workflows/python-app.yml)\n\n# Green Ideas\n\nGreen Ideas is a Python package designed to generate grammatically valid but semantically nonsensical sentences. It is effectively a generative grammar engine, employing recursive rewrite rules to create sentence structures. It can then convert these structures into templates compatible with the `twaddle` package for language templating.\n\n## Features\n\nGreenideas defines a grammar engine which expands a root sentence node into a full sentence\ntree, according to a variety of user-defined rules. Documentation for defining these rules will come at a later date. The package includes a pre-written set of rules which produce (mostly) grammatically valid English sentences. \n\nThe key features of the package are:\n\n- Generation of trees describing valid English sentence structures\n- Support for recursive rewrite rules for sentence structure generation.\n- Converting sentence trees into twaddle-compatible templates.\n- Modular design allowing for easy extension and modification of grammar rules.\n\n## Installation\n\nThe package can be downloaded manually from Github or installed via pip:\n\n```bash\npip install greenideas\n```\n\nThe package uses Poetry for dependency management, dependencies can be installed by running\n\n```bash\npoetry install\n```\n\n## Usage\n\nTo use the `greenideas` package, you can (or at least you will be able to, at some point) import the main classes from the package, provide the location of your twaddle dictionaries, and start generating sentences. The __main__.py file offers a simple example:\n\n```python\nimport readline  # noqa: F401\nimport sys\n\nfrom twaddle.runner import TwaddleRunner\n\nfrom greenideas.grammar_engine import GrammarEngine\nfrom greenideas.parts_of_speech.pos_types import POSType\nfrom greenideas.rules.default_english_rules.default_rules import default_rules\nfrom greenideas.twaddle.default_formatters.default_formatting_handlers import (\n    default_formatting_handlers,\n)\nfrom greenideas.twaddle.twaddle_formatter import TwaddleFormatter\n\n\ndef main():\n    if len(sys.argv) < 2:\n        print(\"argument required: path to directory containing dictionary files\")\n        return\n    dictionary_path = sys.argv[1]\n    twaddle_runner = TwaddleRunner(dictionary_path)\n\n    engine = GrammarEngine()\n    engine.add_ruleset(default_rules)\n    tree = engine.generate_tree(POSType.S)\n    print(tree)\n\n    formatter = TwaddleFormatter()\n    for type, handler in default_formatting_handlers.items():\n        formatter.register_formatting_handler(type, handler)\n\n    twaddle_string = formatter.format_as_sentence(tree)\n    print(twaddle_string)\n    print(twaddle_runner.run_sentence(twaddle_string))\n```\n\nAn official set of twaddle dictionaries for use with the default English language rules is\navailable at https://github.com/chrishengler/greenideas-dict\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a pull request or open an issue for any enhancements or bug fixes.\n\n## License\n\nThis project is licensed under the MIT License. See the LICENSE file for more details.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A package to generate grammatically valid but semantically nonsensical English sentences.",
    "version": "0.6.1",
    "project_urls": {
        "Repository": "https://github.com/chrishengler/greenideas"
    },
    "split_keywords": [
        "grammar",
        " procedural generation",
        " sentence generation",
        " placeholder text",
        " twaddle"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "4f6f094a297cbacb16b761150222466cefd9f6d808e2539819e2e4742e74fc12",
                "md5": "969409f3134ba75b1af4a84ffd63abb9",
                "sha256": "46ab0ae4e4d12ac6ade80d35b0d805eecc540422777949d527e99c6661a65468"
            },
            "downloads": -1,
            "filename": "greenideas-0.6.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "969409f3134ba75b1af4a84ffd63abb9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 44683,
            "upload_time": "2025-08-23T07:54:18",
            "upload_time_iso_8601": "2025-08-23T07:54:18.128082Z",
            "url": "https://files.pythonhosted.org/packages/4f/6f/094a297cbacb16b761150222466cefd9f6d808e2539819e2e4742e74fc12/greenideas-0.6.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "b52fe5cf2e16a61c1c4531b37a9dc96b43913ddaa090621db2edb1d3a7e2b2ec",
                "md5": "20a517c7af4825b0ea68116eda3b955f",
                "sha256": "9b37759fefa7c59b5b109e1b019621c6f49e6bed3058e9d57153b1316909c6bf"
            },
            "downloads": -1,
            "filename": "greenideas-0.6.1.tar.gz",
            "has_sig": false,
            "md5_digest": "20a517c7af4825b0ea68116eda3b955f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 20038,
            "upload_time": "2025-08-23T07:54:19",
            "upload_time_iso_8601": "2025-08-23T07:54:19.462740Z",
            "url": "https://files.pythonhosted.org/packages/b5/2f/e5cf2e16a61c1c4531b37a9dc96b43913ddaa090621db2edb1d3a7e2b2ec/greenideas-0.6.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-23 07:54:19",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "chrishengler",
    "github_project": "greenideas",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "greenideas"
}
        
Elapsed time: 0.63516s