# -*- coding: utf-8 -*-
from setuptools import setup

packages = \
['aida']

package_data = \
{'': ['*']}

setup_kwargs = {
    'name': 'aida-lib',
    'version': '0.3.0',
    'description': 'Aida is a language agnostic library for text generation.',
    'long_description': "# Aida Lib\n\n![](https://github.com/mediatechlab/aida-lib/workflows/Python%20package/badge.svg)\n\nAida is a language agnostic library for text generation.\n\n## Usage\n\nA simple hello world script would look like this:\n\n```Python\nfrom aida import render, Empty, Var\n\n# create a variable to hold a name\nname_var = Var('name')\n\n# create a simple phrase\nnode = (Empty + 'hello,' | name_var).to_phrase()\n\n# assign a value to the variable\nname_var.assign('World')\n\n# render the node\nprint(render(node))  # 'Hello, World.'\n```\n\n## Install\n\nDownload and install with pip:\n\n```bash\npip install aidalib\n```\n\n## Core Concepts\n\nWhen using Aida, first you compose a tree of operations on your text that include conditions via branches and other control flow. Later, you fill the tree with data and render the text.\n\nA building block is the variable class: `Var`. Use it to represent a value that you want to control later. A variable can hold numbers (e.g. `float`, `int`) or strings.\n\nYou can create branches and complex logic with `Branch`. In the example below, if `x` is greater than 1, it will render `many`, otherwise `single`.\n\n```Python\nx = Var('x')\nBranch(x > 1, 'many', 'single')\n```\n\n### Context\n\nThe context, represented by the class `Ctx`, is useful to create rules that depends on what has been written before. Each object or literal that is passed to Aida is remembered by the context.\n\n```Python\nname = Const('Bob')\nalt_name = Const('He')\nbob = Branch(~name.in_ctx(), name, alt_name)\nctx = Ctx()\n\nrender(bob | 'is a cool guy.' | bob | 'doesn\\'t mind.', ctx)\n# Bob is a cool guy. He doesn't mind.\n```\n\nCreating a reference expression is a common use-case, so we have a helper function called `create_ref`.\n\n```Python\nbob = create_ref('Bob', 'He')\n```\n\n### Operators\n\nYou can compose operations on your text with some handy operators.\n\n#### Concatenation (`+` and `|`)\n\n```Python\n'the' | 'quick' | 'brown' | 'fox'  # 'the quick brown fox'\n\n'the' + 'quick' + 'brown' + 'fox'  # 'thequickbrownfox'\n```\n\n#### Check context (`in_ctx`)\n\nCheck if the current node is in the context.\n\n```Python\nConst('something').in_ctx()\n```\n\n#### Create a sentence (`sentence`)\n\nFormats a line into a sentence, capitalizing the first word and adding a period.\n\n```Python\nConst('hello world').sentence()  # 'Hello world.'\n```\n\n#### Logical and numeric operators\n\n| operator              | example  |\n| --------------------- | -------- |\n| negation              | `!x`     |\n| greater than          | `x > y`  |\n| greater or equal than | `x >= y` |\n| less than             | `x < y`  |\n| less or equal than    | `x <= y` |\n| equal                 | `x == y` |\n| not equal             | `x != y` |\n| or                    | `x | y`  |\n| and                   | `x & y`  |\n| plus                  | `x + y`  |\n\n### Random choice\n\nRandomly draws one node from a list of possibilities.\n\n```Python\nChoice('Alice', 'Bob', 'Chris')  # either 'Alice', 'Bob', or 'Chris'\n```\n\n### Injector\n\nThe `Injector` class assigns values to variables from a list each time it is rendered. Very useful to automatically fill values based on data.\n\n```Python\nanimal = Var('animal')\nsound = Var('sound')\nnode = animal | 'makes' | sound\nnode = Injector([animal, sound], node)\n\n# assign multiple values\nnode.assign([\n  {'animal': 'cat', 'sound': 'meaw'},\n  {'animal': 'dog', 'sound': 'roof'},\n])\n\nrender(node) # 'cat makes meaw'\n\nrender(node) # 'dog makes roof'\n```\n\n### For-loops with `Repeat`\n\nUse `Repeat` to render a node multiple times. At the simplest level, you have this:\n\n```Python\nrender(Repeat('buffalo').assign(8))\n# 'buffalo buffalo buffalo buffalo buffalo buffalo buffalo buffalo'\n```\n\n`Repeat` is very useful when used with `Injector`, like this:\n\n```Python\nanimal = Var('animal')\nsound = Var('sound')\nnode = animal | 'makes' | sound\nnode = Injector([animal, sound], node)\nrepeat = Repeat(node)\n\n# assign multiple values\ndata = [\n  {'animal': 'cat', 'sound': 'meaw'},\n  {'animal': 'dog', 'sound': 'roof'},\n]\nnode.assign(data)\nrepeat.assign(len(data))\n\n# renders text based on data\nrender(node)  # cat makes meaw dog makes roof\n```\n\n## Language Concepts\n\nThere are some experimental features that allows you to create text that adapts to common language features, like grammatical _number_ and _person_.\n\n### Enumerate items\n\nUse `LangConfig` to setup language features and then call `create_enumeration()`.\n\n```Python\nfrom aida import create_enumeration, LangConfig, Lang, render\n\nrender(create_enumeration(LangConfig(lang=Lang.ENGLISH), 'Alice', 'Bob', 'Chris'))\n# 'Alice, Bob, and Chris'\n\nrender(create_enumeration(LangConfig(lang=Lang.PORTUGUESE), 'Alice', 'Bob', 'Chris'))\n# 'Alice, Bob e Chris'\n```\n\n### Sentence Structure\n\nYou can compose sentences using special structures: `NP` (noun phrase) and `VP` (verb phrase) along with `LangConfig`.\n\n```Python\nfrom aida import NP, VP, LangConfig\n\nsubj = NP('the dog')\nverb = VP('barked')\n\ns = (subj | verb).sentence()\n\nrender(LangConfig(s))  # The dog barked.\n```\n\nWhat really makes this different from just using `Const` is that we can create rules that change the output of `NP` and `VP` based on various language features. The system will try to use the rule that matches most features from the given `LangConfig`.\n\n```Python\nfrom aida import NP, VP, LangConfig, GNumber, GPerson\n\nsubj = (NP('I')\n        .add_mapping('I', GNumber.SINGULAR, GPerson.FIRST)\n        .add_mapping('he', GNumber.SINGULAR, GPerson.THIRD))\n        .add_mapping('we', GNumber.PLURAL, GPerson.FIRST))\nverb = (VP('drive')\n        .add_mapping('drive', GPerson.FIRST)\n        .add_mapping('drives', GPerson.THIRD))\n\ns = (subj | verb | 'a nice car').sentence()\n\nrender(LangConfig(s, number=GNumber.SINGULAR, person=GPerson.FIRST))  # I drive a nice car.\nrender(LangConfig(s, number=GNumber.SINGULAR, person=GPerson.THIRD))  # He drives a nice car.\nrender(LangConfig(s, number=GNumber.PLURAL, person=GPerson.FIRST))  # We drive a nice car.\n```\n\n## Examples\n\nCheck more complex uses at the [examples folder](examples).\n\n## License\n\nLicensed under the [MIT License](LICENSE).\n",
    'author': 'Giulio Bottari',
    'author_email': 'giuliobottari@gmail.com',
    'maintainer': None,
    'maintainer_email': None,
    'url': None,
    'packages': packages,
    'package_data': package_data,
    'python_requires': '>=3.6,<4.0',
}


setup(**setup_kwargs)
