{"id":37064887,"url":"https://github.com/dodaro/asp2cnl","last_synced_at":"2026-01-14T07:35:26.403Z","repository":{"id":200811885,"uuid":"706056017","full_name":"dodaro/asp2cnl","owner":"dodaro","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-07T15:39:05.000Z","size":416,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2026-01-14T00:02:49.588Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/dodaro.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}},"created_at":"2023-10-17T08:13:09.000Z","updated_at":"2025-04-08T19:11:24.000Z","dependencies_parsed_at":"2023-11-23T19:53:49.846Z","dependency_job_id":"082683f9-7b7d-466e-b31d-d4b2f3654096","html_url":"https://github.com/dodaro/asp2cnl","commit_stats":null,"previous_names":["dodaro/asp2cnl"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dodaro/asp2cnl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dodaro%2Fasp2cnl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dodaro%2Fasp2cnl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dodaro%2Fasp2cnl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dodaro%2Fasp2cnl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dodaro","download_url":"https://codeload.github.com/dodaro/asp2cnl/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dodaro%2Fasp2cnl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28413430,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T05:26:33.345Z","status":"ssl_error","status_checked_at":"2026-01-14T05:21:57.251Z","response_time":107,"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":[],"created_at":"2026-01-14T07:35:25.932Z","updated_at":"2026-01-14T07:35:26.396Z","avatar_url":"https://github.com/dodaro.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ASP2(C)NL \n\nA prototype for automatic converting ASP rules into Controlled Natural Language (CNL) \nsentences in the format supported by the tool CNL2ASP.\n\nASP2(C)NL is composed by two novel and open-source tools, namely ASP2CNL and CNL2NL.\n\nWith ASP2CNL, ASP rules are converted into Controlled Natural Language (CNL) sentences in\nthe format supported by the tool CNL2ASP [1].\n\nSubsequently, CNL2NL translate the obtained CNL sentences into natural language sentences \nusing the state-of-the-art LLM tool ChatGPT. \n\nFinally, the two tools, can be combined together in a pipeline, referred to as ASP2NL, \nthat transforms a given ASP program into a set of sentences expressed in a natural language.\n\n[1]: Caruso, Simone \u0026 Dodaro, Carmine \u0026 Maratea, Marco \u0026 Mochi, Marco \u0026 \n \t\tRiccio, Francesco. (2023). CNL2ASP: Converting Controlled Natural Language Sentences into ASP. \n \t\tTheory and Practice of Logic Programming. 24. 1-31. 10.1017/S1471068423000388. [Link](https://www.cambridge.org/core/journals/theory-and-practice-of-logic-programming/article/cnl2asp-converting-controlled-natural-language-sentences-into-asp/AF5901FADC579E49C583CFD5A10C0192).\n\n\n## Install\n`pip install asp2cnl`\n\n### Dependencies\n- lark\n- inflect\n- multipledispatch\n- cnl2asp\n- openai (optional, only if you plan to use it)\n- requests\n\n### Access to a LLM  is required\n\nIn order to convert CNL into plan natural language the CNL2NL tool needs access to a Large Language Model. \nWe suggest to use an open source library called Ollama which download and run pre-trained LLMs locally. \nAlternatively, OpenAI's ChatGPT can be also invoked but a valid api key is required. The api key must be stored in the environment variable `OPENAI_API_KEY`\n\n#### Install Ollama on Linux\n\n```\ncurl -fsSL https://ollama.com/install.sh | sh\n```\n\nFor installation on other systems, please refer to [Download Ollama](https://ollama.com/download)\n\nNote:By default Ollama launch itself as system service. If you do not want such behaviour, please, run the following command to disable automatic Ollama serving \n```\nsudo systemctl disable ollama.service\n```\n\nOnce completed the installation process we have to download the model we want to use.\nThe simplest way to complete this task is by running the following command  \n\n```\nollama run \u003cLLM MODEL NAME\u003e\n```\nWhere `\u003cLLM MODEL NAME\u003e` is any model present in the Ollama library, an update list can be found at [Ollama - Model List](https://ollama.com/library) \n\nWe suggest to use [openChat](https://ollama.com/library/openchat) as alternative to ChatGPT:\n\n```\nollama run openchat\n```\n\n\n## Getting start\n\n#### ASP2CNL\n\nSyntax to convert an ASP program into Controlled Natural Language (CNL).\n\n``` \nasp2cnl \u003cASP PROGRAM FILE\u003e \u003cDEFINITION FILE\u003e [\u003cOUTPUT JSON FILE\u003e]\n```\n\nThe result will be printed to the standard output as a list of CNL sentences. In the case where \na JSON format is needed, the optional output file can be used, allowing to save the results to a file. \n\nAlternatively, you can run asp2cnl from source using the following command:\n```\npython src/main.py --asp2cnl \u003cASP PROGRAM FILE\u003e \u003cDEFINITION FILE\u003e [\u003cOUTPUT JSON FILE\u003e]\n```\n\nFor example, in order to convert the Maximal Clique ASP program into CNL, we use the following command:\n```\nasp2cnl examples/maxclique/maxclique.asp examples/maxclique/schema.cnl examples/maxclique/maxclique_cnl.json\n```\nThe generated output will be saved into file maxclique_cnl.json in the JSON format.\n\n#### CNL2NL\n\nSyntax to convert a list of CNL sentences into natural language using a LLM\n\n```\ncnl2nl \u003cCNL JSON FILE\u003e [-m \u003cLLM MODEL NAME\u003e] [\u003cOUTPUT JSON FILE\u003e]\n```\n\nThe default value `\u003cLLM MODEL NAME\u003e` is set to  `openchat` and can be omitted. \nResults can be stored into a json file specifying the optional output file.\n\nAlternatively, you can run asp2cnl from source using the following command:\n```\npython src/main.py --cnl2nl \u003cCNL JSON FILE\u003e [-m \u003cLLM MODEL NAME\u003e] [\u003cOUTPUT JSON FILE\u003e]\n```\n\nFor example, in order to convert the Maximal Clique program into NL starting from the CNL output of the previous execution, \nwe use the following command:\n```\ncnl2nl examples/maxclique/maxclique_cnl.json examples/maxclique/maxclique_nl.json\n```\nThe generated output will be saved into file maxclique_nl.json in the JSON format.\n\n#### ASP2NL\n\nSyntax to convert an asp program into natural language via CNL\n\n```\nasp2nl \u003cASP PROGRAM FILE\u003e \u003cDEFINITION FILE\u003e [-m \u003cLLM MODEL NAME\u003e] [\u003cOUTPUT JSON FILE\u003e]\n```\n\nThe default value `\u003cLLM MODEL NAME\u003e` is set to  `openchat` and can be omitted. \nResults can be stored into a json file specifying the optional output file.\n\nAlternatively, you can run asp2cnl from source using the following command:\n```\npython src/main.py --asp2nl \u003cASP PROGRAM FILE\u003e \u003cDEFINITION FILE\u003e [-m \u003cLLM MODEL NAME\u003e] [\u003cOUTPUT JSON FILE\u003e]\n```\n\nFor example, in order to convert the Maximal Clique ASP program into NL, we use the following command:\n```\nasp2nl examples/maxclique/maxclique.asp examples/maxclique/schema.cnl examples/maxclique/maxclique_nl.json\n```\nThe generated output will be saved into file maxclique_nl.json in the JSON format.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdodaro%2Fasp2cnl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdodaro%2Fasp2cnl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdodaro%2Fasp2cnl/lists"}