Datasets:
Tasks:
Translation
Modalities:
Text
Formats:
parquet
Size:
1M - 10M
ArXiv:
Tags:
code-to-text
License:
Convert dataset to Parquet
#5
by albertvillanova HF Staff - opened
Files changed (24)
- README.md+86-37
- code_x_glue_ct_code_to_text.pyDeleted-155
- common.pyDeleted-75
- generated_definitions.pyDeleted-68
- go/test-00000-of-00001.parquetAdded+3
- go/train-00000-of-00001.parquetAdded+3
- go/validation-00000-of-00001.parquetAdded+3
- java/test-00000-of-00001.parquetAdded+3
- java/train-00000-of-00001.parquetAdded+3
- java/validation-00000-of-00001.parquetAdded+3
- javascript/test-00000-of-00001.parquetAdded+3
- javascript/train-00000-of-00001.parquetAdded+3
- javascript/validation-00000-of-00001.parquetAdded+3
- php/test-00000-of-00001.parquetAdded+3
- php/train-00000-of-00002.parquetAdded+3
- php/train-00001-of-00002.parquetAdded+3
- php/validation-00000-of-00001.parquetAdded+3
- python/test-00000-of-00001.parquetAdded+3
- python/train-00000-of-00002.parquetAdded+3
- python/train-00001-of-00002.parquetAdded+3
- python/validation-00000-of-00001.parquetAdded+3
- ruby/test-00000-of-00001.parquetAdded+3
- ruby/train-00000-of-00001.parquetAdded+3
- ruby/validation-00000-of-00001.parquetAdded+3
18 unmodified lines19202122232425 unmodified lines5051525354555657585960616263646522 unmodified lines88899091929394959697989910010110210322 unmodified lines12612712812913013113213313413513613713813914014122 unmodified lines16416516616716816917017117217317417517617717817922 unmodified lines20220320420520620720820921021121221321421521621722 unmodified lines24024124224324424524624724824925025125225325425525625725825926026126218 unmodified lines- translationtask_ids: []pretty_name: CodeXGlueCtCodeToTexttags:- code-to-textdataset_info:25 unmodified linesdtype: stringsplits:- name: trainnum_bytes: 342244027num_examples: 167288- name: validationnum_bytes: 13721912num_examples: 7325- name: testnum_bytes: 16328458num_examples: 8122download_size: 499922799dataset_size: 372294397- config_name: javafeatures:- name: id22 unmodified linesdtype: stringsplits:- name: trainnum_bytes: 452554719num_examples: 164923- name: validationnum_bytes: 13366396num_examples: 5183- name: testnum_bytes: 29080857num_examples: 10955download_size: 1072966017dataset_size: 495001972- config_name: javascriptfeatures:- name: id22 unmodified linesdtype: stringsplits:- name: trainnum_bytes: 160860743num_examples: 58025- name: validationnum_bytes: 10337396num_examples: 3885- name: testnum_bytes: 10190765num_examples: 3291download_size: 1677110214dataset_size: 181388904- config_name: phpfeatures:- name: id22 unmodified linesdtype: stringsplits:- name: trainnum_bytes: 614655799num_examples: 241241- name: validationnum_bytes: 33283149num_examples: 12982- name: testnum_bytes: 35375097num_examples: 14014download_size: 864290912dataset_size: 683314045- config_name: pythonfeatures:- name: id22 unmodified linesdtype: stringsplits:- name: trainnum_bytes: 813664500num_examples: 251820- name: validationnum_bytes: 46888668num_examples: 13914- name: testnum_bytes: 50659792num_examples: 14918download_size: 953306861dataset_size: 911212960- config_name: rubyfeatures:- name: id22 unmodified linesdtype: stringsplits:- name: trainnum_bytes: 51956595num_examples: 24927- name: validationnum_bytes: 2821089num_examples: 1400- name: testnum_bytes: 2671603num_examples: 1261download_size: 124154892dataset_size: 57449287config_names:- go- java- javascript- php- python- ruby---# Dataset Card for "code_x_glue_ct_code_to_text"18 unmodified lines1920212223242526272829303125 unmodified lines5758596061626364656667686970717222 unmodified lines959697989910010110210310410510610710810911022 unmodified lines13313413513613713813914014114214314414514614714822 unmodified lines17117217317417517617717817918018118218318418518622 unmodified lines20921021121221321421521621721821922022122222322422 unmodified lines24724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031118 unmodified lines- translationtask_ids: []pretty_name: CodeXGlueCtCodeToTextconfig_names:- go- java- javascript- php- python- rubytags:- code-to-textdataset_info:25 unmodified linesdtype: stringsplits:- name: trainnum_bytes: 342243143num_examples: 167288- name: validationnum_bytes: 13721860num_examples: 7325- name: testnum_bytes: 16328406num_examples: 8122download_size: 121341698dataset_size: 372293409- config_name: javafeatures:- name: id22 unmodified linesdtype: stringsplits:- name: trainnum_bytes: 452553835num_examples: 164923- name: validationnum_bytes: 13366344num_examples: 5183- name: testnum_bytes: 29080753num_examples: 10955download_size: 154701399dataset_size: 495000932- config_name: javascriptfeatures:- name: id22 unmodified linesdtype: stringsplits:- name: trainnum_bytes: 160860431num_examples: 58025- name: validationnum_bytes: 10337344num_examples: 3885- name: testnum_bytes: 10190713num_examples: 3291download_size: 65788314dataset_size: 181388488- config_name: phpfeatures:- name: id22 unmodified linesdtype: stringsplits:- name: trainnum_bytes: 614654499num_examples: 241241- name: validationnum_bytes: 33283045num_examples: 12982- name: testnum_bytes: 35374993num_examples: 14014download_size: 219692158dataset_size: 683312537- config_name: pythonfeatures:- name: id22 unmodified linesdtype: stringsplits:- name: trainnum_bytes: 813663148num_examples: 251820- name: validationnum_bytes: 46888564num_examples: 13914- name: testnum_bytes: 50659688num_examples: 14918download_size: 325551862dataset_size: 911211400- config_name: rubyfeatures:- name: id22 unmodified linesdtype: stringsplits:- name: trainnum_bytes: 51956439num_examples: 24927- name: validationnum_bytes: 2821037num_examples: 1400- name: testnum_bytes: 2671551num_examples: 1261download_size: 21921316dataset_size: 57449027configs:- config_name: godata_files:- split: trainpath: go/train-*- split: validationpath: go/validation-*- split: testpath: go/test-*- config_name: javadata_files:- split: trainpath: java/train-*- split: validationpath: java/validation-*- split: testpath: java/test-*- config_name: javascriptdata_files:- split: trainpath: javascript/train-*- split: validationpath: javascript/validation-*- split: testpath: javascript/test-*- config_name: phpdata_files:- split: trainpath: php/train-*- split: validationpath: php/validation-*- split: testpath: php/test-*- config_name: pythondata_files:- split: trainpath: python/train-*- split: validationpath: python/validation-*- split: testpath: python/test-*- config_name: rubydata_files:- split: trainpath: ruby/train-*- split: validationpath: ruby/validation-*- split: testpath: ruby/test-*---# Dataset Card for "code_x_glue_ct_code_to_text"
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155import jsonimport osimport os.pathfrom typing import List
import datasets
from .common import TrainValidTestChildfrom .generated_definitions import DEFINITIONS
_DESCRIPTION = """The dataset we use comes from CodeSearchNet and we filter the dataset as the following:- Remove examples that codes cannot be parsed into an abstract syntax tree.- Remove examples that #tokens of documents is < 3 or >256- Remove examples that documents contain special tokens (e.g. <img ...> or https:...)- Remove examples that documents are not English."""_CITATION = """@article{husain2019codesearchnet,title={Codesearchnet challenge: Evaluating the state of semantic code search},author={Husain, Hamel and Wu, Ho-Hsiang and Gazit, Tiferet and Allamanis, Miltiadis and Brockschmidt, Marc},journal={arXiv preprint arXiv:1909.09436},year={2019}}"""
class CodeXGlueCtCodeToTextBaseImpl(TrainValidTestChild): _DESCRIPTION = _DESCRIPTION _CITATION = _CITATION
# For each file, each line in the uncompressed file represents one function. _FEATURES = { "id": datasets.Value("int32"), # Index of the sample "repo": datasets.Value("string"), # repo: the owner/repo "path": datasets.Value("string"), # path: the full path to the original file "func_name": datasets.Value("string"), # func_name: the function or method name "original_string": datasets.Value("string"), # original_string: the raw string before tokenization or parsing "language": datasets.Value("string"), # language: the programming language name "code": datasets.Value("string"), # code/function: the part of the original_string that is code "code_tokens": datasets.features.Sequence( datasets.Value("string") ), # code_tokens/function_tokens: tokenized version of code "docstring": datasets.Value( "string" ), # docstring: the top-level comment or docstring, if it exists in the original string "docstring_tokens": datasets.features.Sequence( datasets.Value("string") ), # docstring_tokens: tokenized version of docstring "sha": datasets.Value("string"), # sha of the file "url": datasets.Value("string"), # url of the file }
_SUPERVISED_KEYS = ["docstring", "docstring_tokens"]
def generate_urls(self, split_name, language): yield "language", f"https://huggingface.co/datasets/code_search_net/resolve/main/data/{language}.zip" yield "dataset", "dataset.zip"
def get_data_files(self, split_name, file_paths, language): language_specific_path = file_paths["language"] final_path = os.path.join(language_specific_path, language, "final") # Make some cleanup to save space for path in os.listdir(final_path): if path.endswith(".pkl"): os.unlink(path)
data_files = [] for root, dirs, files in os.walk(final_path): for file in files: temp = os.path.join(root, file) if ".jsonl" in temp: if split_name in temp: data_files.append(temp) return data_files
def post_process(self, split_name, language, js): return js
def _generate_examples(self, split_name, file_paths, language): import gzip
data_set_path = file_paths["dataset"]
data_files = self.get_data_files(split_name, file_paths, language)
urls = {} f1_path_parts = [data_set_path, "dataset", language, f"{split_name}.txt"] if self.SINGLE_LANGUAGE: del f1_path_parts[2]
f1_path = os.path.join(*f1_path_parts) with open(f1_path, encoding="utf-8") as f1: for line in f1: line = line.strip() urls[line] = True
idx = 0 for file in data_files: if ".gz" in file: f = gzip.open(file) else: f = open(file, encoding="utf-8")
for line in f: line = line.strip() js = json.loads(line) if js["url"] in urls: js["id"] = idx js = self.post_process(split_name, language, js) if "partition" in js: del js["partition"] yield idx, js idx += 1 f.close()
class CodeXGlueCtCodeToTextImpl(CodeXGlueCtCodeToTextBaseImpl): SINGLE_LANGUAGE = False
def generate_urls(self, split_name): language = self.info["parameters"]["language"] for e in super().generate_urls(split_name, language): yield e
def _generate_examples(self, split_name, file_paths): language = self.info["parameters"]["language"] for e in super()._generate_examples(split_name, file_paths, language): yield e
CLASS_MAPPING = { "CodeXGlueCtCodeToText": CodeXGlueCtCodeToTextImpl,}
class CodeXGlueCtCodeToText(datasets.GeneratorBasedBuilder): BUILDER_CONFIG_CLASS = datasets.BuilderConfig BUILDER_CONFIGS = [ datasets.BuilderConfig(name=name, description=info["description"]) for name, info in DEFINITIONS.items() ]
def _info(self): name = self.config.name info = DEFINITIONS[name] if info["class_name"] in CLASS_MAPPING: self.child = CLASS_MAPPING[info["class_name"]](info) else: raise RuntimeError(f"Unknown python class for dataset configuration {name}") ret = self.child._info() return ret
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]: return self.child._split_generators(dl_manager=dl_manager)
def _generate_examples(self, split_name, file_paths): return self.child._generate_examples(split_name, file_paths)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475from typing import List
import datasets
# Citation, taken from https://github.com/microsoft/CodeXGLUE_DEFAULT_CITATION = """@article{CodeXGLUE, title={CodeXGLUE: A Benchmark Dataset and Open Challenge for Code Intelligence}, year={2020},}"""
class Child: _DESCRIPTION = None _FEATURES = None _CITATION = None SPLITS = {"train": datasets.Split.TRAIN} _SUPERVISED_KEYS = None
def __init__(self, info): self.info = info
def homepage(self): return self.info["project_url"]
def _info(self): # This is the description that will appear on the datasets page. return datasets.DatasetInfo( description=self.info["description"] + "\n\n" + self._DESCRIPTION, features=datasets.Features(self._FEATURES), homepage=self.homepage(), citation=self._CITATION or _DEFAULT_CITATION, supervised_keys=self._SUPERVISED_KEYS, )
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]: SPLITS = self.SPLITS _URL = self.info["raw_url"] urls_to_download = {} for split in SPLITS: if split not in urls_to_download: urls_to_download[split] = {}
for key, url in self.generate_urls(split): if not url.startswith("http"): url = _URL + "/" + url urls_to_download[split][key] = url
downloaded_files = {} for k, v in urls_to_download.items(): downloaded_files[k] = dl_manager.download_and_extract(v)
return [ datasets.SplitGenerator( name=SPLITS[k], gen_kwargs={"split_name": k, "file_paths": downloaded_files[k]}, ) for k in SPLITS ]
def check_empty(self, entries): all_empty = all([v == "" for v in entries.values()]) all_non_empty = all([v != "" for v in entries.values()])
if not all_non_empty and not all_empty: raise RuntimeError("Parallel data files should have the same number of lines.")
return all_empty
class TrainValidTestChild(Child): SPLITS = { "train": datasets.Split.TRAIN, "valid": datasets.Split.VALIDATION, "test": datasets.Split.TEST, }1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768DEFINITIONS = { "go": { "class_name": "CodeXGlueCtCodeToText", "dataset_type": "Code-Text", "description": "CodeXGLUE code-to-text dataset, available at https://github.com/microsoft/CodeXGLUE/tree/main/Code-Text/code-to-text", "dir_name": "code-to-text", "name": "go", "parameters": {"language": "go"}, "project_url": "https://github.com/madlag/CodeXGLUE/tree/main/Code-Text/code-to-text", "raw_url": "https://raw.githubusercontent.com/madlag/CodeXGLUE/main/Code-Text/code-to-text", "sizes": {"test": 8122, "train": 167288, "validation": 7325}, }, "java": { "class_name": "CodeXGlueCtCodeToText", "dataset_type": "Code-Text", "description": "CodeXGLUE code-to-text dataset, available at https://github.com/microsoft/CodeXGLUE/tree/main/Code-Text/code-to-text", "dir_name": "code-to-text", "name": "java", "parameters": {"language": "java"}, "project_url": "https://github.com/madlag/CodeXGLUE/tree/main/Code-Text/code-to-text", "raw_url": "https://raw.githubusercontent.com/madlag/CodeXGLUE/main/Code-Text/code-to-text", "sizes": {"test": 10955, "train": 164923, "validation": 5183}, }, "javascript": { "class_name": "CodeXGlueCtCodeToText", "dataset_type": "Code-Text", "description": "CodeXGLUE code-to-text dataset, available at https://github.com/microsoft/CodeXGLUE/tree/main/Code-Text/code-to-text", "dir_name": "code-to-text", "name": "javascript", "parameters": {"language": "javascript"}, "project_url": "https://github.com/madlag/CodeXGLUE/tree/main/Code-Text/code-to-text", "raw_url": "https://raw.githubusercontent.com/madlag/CodeXGLUE/main/Code-Text/code-to-text", "sizes": {"test": 3291, "train": 58025, "validation": 3885}, }, "php": { "class_name": "CodeXGlueCtCodeToText", "dataset_type": "Code-Text", "description": "CodeXGLUE code-to-text dataset, available at https://github.com/microsoft/CodeXGLUE/tree/main/Code-Text/code-to-text", "dir_name": "code-to-text", "name": "php", "parameters": {"language": "php"}, "project_url": "https://github.com/madlag/CodeXGLUE/tree/main/Code-Text/code-to-text", "raw_url": "https://raw.githubusercontent.com/madlag/CodeXGLUE/main/Code-Text/code-to-text", "sizes": {"test": 14014, "train": 241241, "validation": 12982}, }, "python": { "class_name": "CodeXGlueCtCodeToText", "dataset_type": "Code-Text", "description": "CodeXGLUE code-to-text dataset, available at https://github.com/microsoft/CodeXGLUE/tree/main/Code-Text/code-to-text", "dir_name": "code-to-text", "name": "python", "parameters": {"language": "python"}, "project_url": "https://github.com/madlag/CodeXGLUE/tree/main/Code-Text/code-to-text", "raw_url": "https://raw.githubusercontent.com/madlag/CodeXGLUE/main/Code-Text/code-to-text", "sizes": {"test": 14918, "train": 251820, "validation": 13914}, }, "ruby": { "class_name": "CodeXGlueCtCodeToText", "dataset_type": "Code-Text", "description": "CodeXGLUE code-to-text dataset, available at https://github.com/microsoft/CodeXGLUE/tree/main/Code-Text/code-to-text", "dir_name": "code-to-text", "name": "ruby", "parameters": {"language": "ruby"}, "project_url": "https://github.com/madlag/CodeXGLUE/tree/main/Code-Text/code-to-text", "raw_url": "https://raw.githubusercontent.com/madlag/CodeXGLUE/main/Code-Text/code-to-text", "sizes": {"test": 1261, "train": 24927, "validation": 1400}, },}123version https://git-lfs.github.com/spec/v1oid sha256:5e4faa7c186c60891fad6dba97adde01e706243e2a10f03e39f457a3db1600cbsize 5432557123version https://git-lfs.github.com/spec/v1oid sha256:da6535760b76ab1aa1a74f2e57672f7bdcad3d7cbe23e44836125ae6da190a69size 111614231123version https://git-lfs.github.com/spec/v1oid sha256:22a813598a30ed4e526873a98d292fc0710caef769748370ca5275bcead95a60size 4294910123version https://git-lfs.github.com/spec/v1oid sha256:38e2806527d689ee75109e035ba3d3031497b1c9c0bea0055795ac72c8557c94size 9378593123version https://git-lfs.github.com/spec/v1oid sha256:9c1f85dd441e2ea99fd9c9d04e26784d75a0bffc6f1c91b5eb8499ab86fda20bsize 141076943123version https://git-lfs.github.com/spec/v1oid sha256:6a4890bb491a03e3442a15b454b41d202fd95521d4a506a5fc5afddcb581755dsize 4245863123version https://git-lfs.github.com/spec/v1oid sha256:bb485b1b996bd78cd5fea0c9105b3c648d72c268b97b63344d09fce7b5ef37d0size 3593407123version https://git-lfs.github.com/spec/v1oid sha256:8fa783615e9ddbefea9eb56a945c66e303f4d617c79ae7ec936346bbf1236c2dsize 58415544123version https://git-lfs.github.com/spec/v1oid sha256:967e3a6d2d0f730ca1d194aef0ca64dabec98741b4ca3003dc0c73ad73b67923size 3779363123version https://git-lfs.github.com/spec/v1oid sha256:def714be2c74037aaa08a22167e46952fd1e61d0e4d3457f6f0110c2aebe2b96size 11160469123version https://git-lfs.github.com/spec/v1oid sha256:dee7ca8ecdfe70c3b0213666844aeaffd526173ddafb74b2c31b599379f8c9desize 97692232123version https://git-lfs.github.com/spec/v1oid sha256:e7cf5cc5d45cfd1ed4f505e8ce97084e7521d9f8289363896f904e4e5b2a1915size 100304628123version https://git-lfs.github.com/spec/v1oid sha256:12487b8af8760b45ea89c8f3243bb1533c9cb8c0c0ccc77fd33489eb9192ed48size 10534829123version https://git-lfs.github.com/spec/v1oid sha256:69acf4b46f35ffdf5e4184615d99feb08b96b388ae6891744c0b73ae3f564e9esize 17972583123version https://git-lfs.github.com/spec/v1oid sha256:9decfb7a7e4eb455fc585815b4fad828830183e3b7be8266638a7abf924a56cdsize 144077099123version https://git-lfs.github.com/spec/v1oid sha256:d7f108a8a5418f7f8ad267965ab39c81096a1cc8812019f3e240499e8d05364csize 146851339123version https://git-lfs.github.com/spec/v1oid sha256:e078006b8829aed4cb087e2003e76d5308b94817740fd9af817ac5cf52a24ce2size 16650841123version https://git-lfs.github.com/spec/v1oid sha256:39597f63eb27343b21bc68a532fffd739760a38bec6bdba8eeceb4e6ccd04a48size 1030532123version https://git-lfs.github.com/spec/v1oid sha256:a96dc16c07f1802ddd3f46f82680527e18cabeacf1d5e00954cdb69b5962faf4size 19831678123version https://git-lfs.github.com/spec/v1oid sha256:ef0c3acd6ebd6be0bf36859debbef7695915ed52304d06f66222a9c1c276d86esize 1059106README.md+86-37
code_x_glue_ct_code_to_text.pyDeleted-155
common.pyDeleted-75
generated_definitions.pyDeleted-68
go/test-00000-of-00001.parquetAdded+3
go/train-00000-of-00001.parquetAdded+3
go/validation-00000-of-00001.parquetAdded+3
java/test-00000-of-00001.parquetAdded+3
java/train-00000-of-00001.parquetAdded+3
java/validation-00000-of-00001.parquetAdded+3
javascript/test-00000-of-00001.parquetAdded+3
javascript/train-00000-of-00001.parquetAdded+3
javascript/validation-00000-of-00001.parquetAdded+3
php/test-00000-of-00001.parquetAdded+3
php/train-00000-of-00002.parquetAdded+3
php/train-00001-of-00002.parquetAdded+3
php/validation-00000-of-00001.parquetAdded+3
python/test-00000-of-00001.parquetAdded+3
python/train-00000-of-00002.parquetAdded+3
python/train-00001-of-00002.parquetAdded+3
python/validation-00000-of-00001.parquetAdded+3
ruby/test-00000-of-00001.parquetAdded+3
ruby/train-00000-of-00001.parquetAdded+3
ruby/validation-00000-of-00001.parquetAdded+3