rasa-gen


Namerasa-gen JSON
Version 0.0.3 PyPI version JSON
download
home_pagehttps://github.com/SchweitzerGAO/rasa-train-generator
SummaryRasa train data generator
upload_time2023-04-19 08:04:12
maintainer
docs_urlNone
authorCharles Gao
requires_python
licenseApache License 2.0
keywords rasa chatbot rasa pip
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # RasaGen: A [Rasa](https://github.com/RasaHQ/rasa) chatbot training data generator
([中文版](docs/README_CN.md)) | (English)
## Installation

Install the latest version of `RasaGen` by running:
```
pip install rasa_gen
```
or install with source code:
```
pip install git+https://github.com/SchweitzerGAO/rasa-train-generator
```
## Basic usage
**An Example**

_Though the template in this example is in Chinese, It supports mainstream languages like English, French and Japanese etc._

```python
from rasa_gen import NLUTemplate, Generator

if __name__ == '__main__':
    sentence_template = [
        '[{}](operation_set_temp)[{}]{{"entity":"value","role":"temperature"}}度',
        '把[{}](operation_set_temp)[{}]{{"entity":"value","role":"temperature"}}度',
        '空调[{}](operation_set_temp)[{}]{{"entity":"value","role":"temperature"}}度',
        '把空调[{}](operation_set_temp)[{}]{{"entity":"value","role":"temperature"}}度',

    ]
    word_template = [
        '温度降低到', '温度升高到', '温度升高至', '温度降低至', '温度调整到', '温度调整至', '温度调到', '温度调至',
    ]
    template = NLUTemplate().add_sentence(sentence_template)\
                            .add_word(word_template)\
                            .add_random_val(16, 30)
generator = Generator('test_intent').add_template(template)
generator.generate_from_template(50, './test_template.yml')
```
A detailed example is in `example.py`


**Creating a `NLUTemplate`**

As shown in the example, 
you can create a NLU training data generating template by creating a `NLUTemplate` instance and add sentence, 
word and random value to fill 
in the template in a streaming way.

**Using a `Generator`**

1. Create a `Generator`

You can create a `Generator` instance 
with specifying the name of the key of the training data. 
For example, 
you shall specify the name of `intent` 
when generating data for an intent
or the name of `lookup` for a lookup table.

**Note: If you are generating data from a csv or tsv file 
with the name of `lookup` in the first column, 
there is no need to specify 
the name when creating a `Generator`**

For now, only `intent` and `lookup` data types in `nlu` class are supported.
Other types like `rule` and `story` 
will be supported in the future

2. Generate data by a `Generator`

There are 2 supported ways to generate data by a `Generator`
- From a template (Recommended for `intent` data)

You can add a `Template` instance by `add_template` method and generate the data by `generate_from_template` method.

- From a file (Recommended for `lookup` data)

There is no need to create `Template` instances. 
Just specify the input file and output file 
and use the `generate_from_file` method will be OK. 

## Coming Soon...
- Generating `story`, `synonym` and `rule` data

- The detailed [document](https://github.com/SchweitzerGAO/rasa-train-generator) will be released soon.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/SchweitzerGAO/rasa-train-generator",
    "name": "rasa-gen",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "Rasa chatbot,Rasa,pip",
    "author": "Charles Gao",
    "author_email": "charlesgao2101024@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/48/96/dc172d3a02bd547b7a06fd21b13417096cec30ed0724ac9f8882bf0d4f00/rasa_gen-0.0.3.tar.gz",
    "platform": "any",
    "description": "# RasaGen: A [Rasa](https://github.com/RasaHQ/rasa) chatbot training data generator\r\n([\u4e2d\u6587\u7248](docs/README_CN.md)) | (English)\r\n## Installation\r\n\r\nInstall the latest version of `RasaGen` by running:\r\n```\r\npip install rasa_gen\r\n```\r\nor install with source code:\r\n```\r\npip install git+https://github.com/SchweitzerGAO/rasa-train-generator\r\n```\r\n## Basic usage\r\n**An Example**\r\n\r\n_Though the template in this example is in Chinese, It supports mainstream languages like English, French and Japanese etc._\r\n\r\n```python\r\nfrom rasa_gen import NLUTemplate, Generator\r\n\r\nif __name__ == '__main__':\r\n    sentence_template = [\r\n        '[{}](operation_set_temp)[{}]{{\"entity\":\"value\",\"role\":\"temperature\"}}\u5ea6',\r\n        '\u628a[{}](operation_set_temp)[{}]{{\"entity\":\"value\",\"role\":\"temperature\"}}\u5ea6',\r\n        '\u7a7a\u8c03[{}](operation_set_temp)[{}]{{\"entity\":\"value\",\"role\":\"temperature\"}}\u5ea6',\r\n        '\u628a\u7a7a\u8c03[{}](operation_set_temp)[{}]{{\"entity\":\"value\",\"role\":\"temperature\"}}\u5ea6',\r\n\r\n    ]\r\n    word_template = [\r\n        '\u6e29\u5ea6\u964d\u4f4e\u5230', '\u6e29\u5ea6\u5347\u9ad8\u5230', '\u6e29\u5ea6\u5347\u9ad8\u81f3', '\u6e29\u5ea6\u964d\u4f4e\u81f3', '\u6e29\u5ea6\u8c03\u6574\u5230', '\u6e29\u5ea6\u8c03\u6574\u81f3', '\u6e29\u5ea6\u8c03\u5230', '\u6e29\u5ea6\u8c03\u81f3',\r\n    ]\r\n    template = NLUTemplate().add_sentence(sentence_template)\\\r\n                            .add_word(word_template)\\\r\n                            .add_random_val(16, 30)\r\ngenerator = Generator('test_intent').add_template(template)\r\ngenerator.generate_from_template(50, './test_template.yml')\r\n```\r\nA detailed example is in `example.py`\r\n\r\n\r\n**Creating a `NLUTemplate`**\r\n\r\nAs shown in the example, \r\nyou can create a NLU training data generating template by creating a `NLUTemplate` instance and add sentence, \r\nword and random value to fill \r\nin the template in a streaming way.\r\n\r\n**Using a `Generator`**\r\n\r\n1. Create a `Generator`\r\n\r\nYou can create a `Generator` instance \r\nwith specifying the name of the key of the training data. \r\nFor example, \r\nyou shall specify the name of `intent` \r\nwhen generating data for an intent\r\nor the name of `lookup` for a lookup table.\r\n\r\n**Note: If you are generating data from a csv or tsv file \r\nwith the name of `lookup` in the first column, \r\nthere is no need to specify \r\nthe name when creating a `Generator`**\r\n\r\nFor now, only `intent` and `lookup` data types in `nlu` class are supported.\r\nOther types like `rule` and `story` \r\nwill be supported in the future\r\n\r\n2. Generate data by a `Generator`\r\n\r\nThere are 2 supported ways to generate data by a `Generator`\r\n- From a template (Recommended for `intent` data)\r\n\r\nYou can add a `Template` instance by `add_template` method and generate the data by `generate_from_template` method.\r\n\r\n- From a file (Recommended for `lookup` data)\r\n\r\nThere is no need to create `Template` instances. \r\nJust specify the input file and output file \r\nand use the `generate_from_file` method will be OK. \r\n\r\n## Coming Soon...\r\n- Generating `story`, `synonym` and `rule` data\r\n\r\n- The detailed [document](https://github.com/SchweitzerGAO/rasa-train-generator) will be released soon.\r\n",
    "bugtrack_url": null,
    "license": "Apache License 2.0",
    "summary": "Rasa train data generator",
    "version": "0.0.3",
    "split_keywords": [
        "rasa chatbot",
        "rasa",
        "pip"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4896dc172d3a02bd547b7a06fd21b13417096cec30ed0724ac9f8882bf0d4f00",
                "md5": "5b85a5e7b0ad4866e4f3fa79284f4d62",
                "sha256": "2e6181136ef4357f0fcbe8c4e5cf331cd78776141fbc6e331e48472ed2eadb73"
            },
            "downloads": -1,
            "filename": "rasa_gen-0.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "5b85a5e7b0ad4866e4f3fa79284f4d62",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 9253,
            "upload_time": "2023-04-19T08:04:12",
            "upload_time_iso_8601": "2023-04-19T08:04:12.063235Z",
            "url": "https://files.pythonhosted.org/packages/48/96/dc172d3a02bd547b7a06fd21b13417096cec30ed0724ac9f8882bf0d4f00/rasa_gen-0.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-19 08:04:12",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "SchweitzerGAO",
    "github_project": "rasa-train-generator",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "rasa-gen"
}
        
Elapsed time: 0.07876s