{"id":17614337,"url":"https://github.com/sumith1896/spoc","last_synced_at":"2025-04-30T17:02:48.246Z","repository":{"id":85971029,"uuid":"215394841","full_name":"sumith1896/spoc","owner":"sumith1896","description":"Official code release of our NeurIPS '19 paper \"SPoC: Search-based Pseudocode to Code\"","archived":false,"fork":false,"pushed_at":"2022-12-18T21:36:44.000Z","size":20533,"stargazers_count":15,"open_issues_count":2,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-30T17:02:40.194Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sumith1896.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"publiccode":null,"codemeta":null}},"created_at":"2019-10-15T20:54:30.000Z","updated_at":"2025-01-17T21:37:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"82478b3a-c13d-4c39-8941-8e2279809324","html_url":"https://github.com/sumith1896/spoc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sumith1896%2Fspoc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sumith1896%2Fspoc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sumith1896%2Fspoc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sumith1896%2Fspoc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sumith1896","download_url":"https://codeload.github.com/sumith1896/spoc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251748934,"owners_count":21637414,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":"2024-10-22T18:43:33.910Z","updated_at":"2025-04-30T17:02:48.208Z","avatar_url":"https://github.com/sumith1896.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SPoC: Search-based Pseudocode to Code\n\n[[Paper](https://arxiv.org/abs/1906.04908)] [[Webpage](https://cs.stanford.edu/~sumith/spoc)] [[Codalab](https://worksheets.codalab.org/worksheets/0xd445b1bd087d46d3b84f2dcf9a8094fa)]\n\nFor your convenience, we provide a docker image as well as preprocessed data along with original data.\n\n## Dependencies\n\n* GCC: TODO\n* Python: 3.6.5\n* PyTorch: 0.4.1\n\n```\npip install cython\npip install tqdm\n```\n\n**Docker** (WIP, currently not updated)\n\n```\ndocker build -t sumith1896/spoc .\ndocker run -it sumith1896/spoc bash\n```\n\n**Code**\nWe use a modified version of [OpenNMT-py](https://github.com/OpenNMT/OpenNMT-py) as our `translator`, bundled with this repository.\n\n```\ngit clone https://github.com/Sumith1896/synlp.git\ncd synlp\n```\n\n## Data\n\nGet the dataset:\n\n```\nwget https://sumith1896.github.io/spoc/data/spoc.zip\nunzip spoc.zip \u0026\u0026 mv spoc/ data/ \u0026\u0026 rm spoc.zip\n```\n\nFor tokenization of code, we rely on Clang (7.0.1). Fetch the right version of Clang:\n\n```\nwget http://releases.llvm.org/7.0.1/clang+llvm-7.0.1-x86_64-linux-gnu-ubuntu-16.04.tar.xz\ntar -xf clang+llvm-7.0.1-x86_64-linux-gnu-ubuntu-16.04.tar.xz\nmkdir tokenizer/lib\nmv clang+llvm-7.0.1-x86_64-linux-gnu-ubuntu-16.04/lib/libclang.so.7 tokenizer/lib/libclang.so\nrm -rf clang+llvm-7.0.1-x86_64-linux-gnu-ubuntu-16.04\nrm clang+llvm-7.0.1-x86_64-linux-gnu-ubuntu-16.04.tar.xz \n```\n\nFinally, tokenize the data:\n\n```\n./tokenizer/format-pairs.py -c ./tokenizer/lib -H -t data/train/split/spoc-train-train.tsv \u003e data/input-tok-train.tsv\n./tokenizer/format-pairs.py -c ./tokenizer/lib -H -t data/train/split/spoc-train-eval.tsv \u003e data/input-tok-eval.tsv\n./tokenizer/format-pairs.py -c ./tokenizer/lib -H -t data/train/split/spoc-train-test.tsv \u003e data/input-tok-test.tsv\n```\n\n## Translation\n\nPreprocessing the data (or download [this preprocessed data](https://worksheets.codalab.org/worksheets/0xd445b1bd087d46d3b84f2dcf9a8094fa) from the CodaLab platform):\n\n```\nshuf data/input-tok-train.tsv -o data/input-tok-train-shuf.tsv\nmkdir out\n./translator/preprocess.py -config translator/config/config.preprocess.yml \u003e preprocess.log\n```\n\nTraining the translation model:\n\n```\n./translator/train.py -config translator/config/config.train.yml \u003e train.log\n```\n\n```\ngrep 'Validation.*accuracy\\|Saving' train.log\n```\n\nEvaluating translation model on test split:\n\n```\n# Separate test source (pseudocode) and target data (code) \ncut -f1 data/input-tok-test.tsv \u003e data/input-tok-test-src.tsv\ncut -f2 data/input-tok-test.tsv \u003e data/input-tok-test-tgt.tsv\n\n# Run inference (w/ beam search) for test\n./translator/translate.py -config translator/config/config.translate.yml -model out/model_best.pt -log_file out/translate.log\n\n# Get summary statistics of result\n./translator/evaluate.py out/translate.log data/input-tok-test-tgt.tsv -o out/translate.summary-nodummy -a | tee out/translate.stats\n\n# Insert back dummy lines that were not translated\n./translator/recover-dummy.py data/train/split/spoc-train-test.tsv out/translate.summary-nodummy \u003e out/translate.summary\n```\n\n## Stitching\n\n```\ncp out/translate.summary out/spoc-train-test.summary\ncp ../data/train/split/spoc-train-test.tsv out/\nbash stitcher/stitching.sh out/spoc-train-test\n\n## TODO use different options\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsumith1896%2Fspoc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsumith1896%2Fspoc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsumith1896%2Fspoc/lists"}