varwizard


Namevarwizard JSON
Version 0.2.2 PyPI version JSON
download
home_pagehttps://github.com/FSoft-AI4Code/VarWizard
SummaryAn Automated Tool for Improving Code Quality Through Variable Name Refinement with Language Models
upload_time2023-05-27 18:13:15
maintainer
docs_urlNone
authorFSoft-AI4Code
requires_python>=3.7
licenseApache-2.0
keywords variable renaming language models code quality
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ### VarWizard
***
1. Introduction

VarWizard is a language model-based tool to help generate more meaningful variable names in source code than the original version. It supports 10 programming languages: c, cpp, java, javascript, go, python, php, c\_sharp, ruby, rust.

2. Installation

You can easily install this package by the command
```bash
    pip install varwizard
```
3. Usage
    * Command-line
    
    You can use VarWizard by running the command
```bash
varwizard [--model-name {bloom-560m, codet5-base} (default: bloom-560m)]
            --input INPUT --lang {c,cpp,java,php,go,javascript,ruby,rust,python,c_sharp} 
            [--output-path OUTPUT_PATH (default: None)] [--max-input-len MAX_INPUT_LEN (default: 400)]
            [--device DEVICE (default: cpu)] [--penalty-alpha PENALTY_ALPHA (default: 0.6)] [--top-k TOP_K (default: 4)] [--max-new-tokens MAX_NEW_TOKENS (default: 100)]
```
Details for each argument can be found by 
```varwizard --help```


 * Python API

    Another way is to Python methods.
Here is a simple example of VarWizard.
```python
from varwizard import VarWizard

model = VarWizard(model_name = "codet5-base")
code = """
function chunkData(str, chunk) {
  var chunk = [];
  var length = str.length;
  var i = 0;
  for (; i < length; i += chunk) {
    if (i + chunk < length) {
      chunk.push(str.substring(i, i + chunk));
    } else {
      chunk.push(str.substring(i, length));
    }
  }
  return chunk;
}
"""
print(model.make_new_code(code, 'javascript', device = 'cuda:0'))
```
VarWizard produces the output
```javascript
function chunkData(str, chunk) {
  var chunk = [];
  var length = str.length;
  var i = 0;
  for (; i < length; i += chunk) {
    if (i + chunk < length) {
      chunk.push(str.substring(i, i + chunk));
    } else {
      chunk.push(str.substring(i, length));
    }
  }
  return chunk;
}
```

4. Playground: You can play at the link: https://varwizard.loca.lt. At the first time to access, you may need to enter: 4.193.50.237
5. Examples

There are some examples for varWizard's usage. We can navigate to the folder $examples$ and then go to any subfolder to run the script.
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/FSoft-AI4Code/VarWizard",
    "name": "varwizard",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "variable renaming,language models,code quality",
    "author": "FSoft-AI4Code",
    "author_email": "support.aic@fpt.com",
    "download_url": "https://files.pythonhosted.org/packages/7f/d6/ae9bc48ddd0eae0e3b39e5837e4aa803ad9c924eb08035cf6c85079017a0/varwizard-0.2.2.tar.gz",
    "platform": null,
    "description": "### VarWizard\n***\n1. Introduction\n\nVarWizard is a language model-based tool to help generate more meaningful variable names in source code than the original version. It supports 10 programming languages: c, cpp, java, javascript, go, python, php, c\\_sharp, ruby, rust.\n\n2. Installation\n\nYou can easily install this package by the command\n```bash\n    pip install varwizard\n```\n3. Usage\n    * Command-line\n    \n    You can use VarWizard by running the command\n```bash\nvarwizard [--model-name {bloom-560m, codet5-base} (default: bloom-560m)]\n            --input INPUT --lang {c,cpp,java,php,go,javascript,ruby,rust,python,c_sharp} \n            [--output-path OUTPUT_PATH (default: None)] [--max-input-len MAX_INPUT_LEN (default: 400)]\n            [--device DEVICE (default: cpu)] [--penalty-alpha PENALTY_ALPHA (default: 0.6)] [--top-k TOP_K (default: 4)] [--max-new-tokens MAX_NEW_TOKENS (default: 100)]\n```\nDetails for each argument can be found by \n```varwizard --help```\n\n\n * Python API\n\n    Another way is to Python methods.\nHere is a simple example of VarWizard.\n```python\nfrom varwizard import VarWizard\n\nmodel = VarWizard(model_name = \"codet5-base\")\ncode = \"\"\"\nfunction chunkData(str, chunk) {\n  var chunk = [];\n  var length = str.length;\n  var i = 0;\n  for (; i < length; i += chunk) {\n    if (i + chunk < length) {\n      chunk.push(str.substring(i, i + chunk));\n    } else {\n      chunk.push(str.substring(i, length));\n    }\n  }\n  return chunk;\n}\n\"\"\"\nprint(model.make_new_code(code, 'javascript', device = 'cuda:0'))\n```\nVarWizard produces the output\n```javascript\nfunction chunkData(str, chunk) {\n  var chunk = [];\n  var length = str.length;\n  var i = 0;\n  for (; i < length; i += chunk) {\n    if (i + chunk < length) {\n      chunk.push(str.substring(i, i + chunk));\n    } else {\n      chunk.push(str.substring(i, length));\n    }\n  }\n  return chunk;\n}\n```\n\n4. Playground: You can play at the link: https://varwizard.loca.lt. At the first time to access, you may need to enter: 4.193.50.237\n5. Examples\n\nThere are some examples for varWizard's usage. We can navigate to the folder $examples$ and then go to any subfolder to run the script.",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "An Automated Tool for Improving Code Quality Through Variable Name Refinement with Language Models",
    "version": "0.2.2",
    "project_urls": {
        "Homepage": "https://github.com/FSoft-AI4Code/VarWizard",
        "Repository": "https://github.com/FSoft-AI4Code/VarWizard"
    },
    "split_keywords": [
        "variable renaming",
        "language models",
        "code quality"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "65ae05b48221e8f370cc5ce59b214956a2e804351baffa4799ffe68ec5d581f0",
                "md5": "e687ba9983f916500d95fa4929fcf33a",
                "sha256": "c40f397a269e8cac531397719a2391b57398886ee417153109db26d5f16624aa"
            },
            "downloads": -1,
            "filename": "varwizard-0.2.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e687ba9983f916500d95fa4929fcf33a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 1129310,
            "upload_time": "2023-05-27T18:13:11",
            "upload_time_iso_8601": "2023-05-27T18:13:11.755425Z",
            "url": "https://files.pythonhosted.org/packages/65/ae/05b48221e8f370cc5ce59b214956a2e804351baffa4799ffe68ec5d581f0/varwizard-0.2.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7fd6ae9bc48ddd0eae0e3b39e5837e4aa803ad9c924eb08035cf6c85079017a0",
                "md5": "e9c2e946042e2ed42817d435c50a3088",
                "sha256": "a00466ad12299a2cb07a85b9436d5c2cd45cbd4acebc042250c206589528b564"
            },
            "downloads": -1,
            "filename": "varwizard-0.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "e9c2e946042e2ed42817d435c50a3088",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 1102286,
            "upload_time": "2023-05-27T18:13:15",
            "upload_time_iso_8601": "2023-05-27T18:13:15.942098Z",
            "url": "https://files.pythonhosted.org/packages/7f/d6/ae9bc48ddd0eae0e3b39e5837e4aa803ad9c924eb08035cf6c85079017a0/varwizard-0.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-27 18:13:15",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "FSoft-AI4Code",
    "github_project": "VarWizard",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "varwizard"
}
        
Elapsed time: 0.07214s