Convert dataset to Parquet
#2
by albertvillanova HF Staff - opened
Files changed (10)
- README.md+50-25
- code_x_glue_cc_cloze_testing_maxmin.pyDeleted-83
- common.pyDeleted-75
- generated_definitions.pyDeleted-68
- go/train-00000-of-00001.parquetAdded+3
- java/train-00000-of-00001.parquetAdded+3
- javascript/train-00000-of-00001.parquetAdded+3
- php/train-00000-of-00001.parquetAdded+3
- python/train-00000-of-00001.parquetAdded+3
- ruby/train-00000-of-00001.parquetAdded+3
19 unmodified lines2021222324257 unmodified lines333435363738394041426 unmodified lines495051525354555657586 unmodified lines656667686970717273746 unmodified lines818283848586878889906 unmodified lines9798991001011021031041051066 unmodified lines11311411511611711811912012112212312412512612712812919 unmodified linestask_ids:- slot-fillingpretty_name: CodeXGlueCcClozeTestingMaxmindataset_info:- config_name: gofeatures:7 unmodified linessequence: stringsplits:- name: trainnum_bytes: 204997num_examples: 152download_size: 298893dataset_size: 204997- config_name: javafeatures:- name: id6 unmodified linessequence: stringsplits:- name: trainnum_bytes: 785754num_examples: 482download_size: 1097733dataset_size: 785754- config_name: javascriptfeatures:- name: id6 unmodified linessequence: stringsplits:- name: trainnum_bytes: 594347num_examples: 272download_size: 836112dataset_size: 594347- config_name: phpfeatures:- name: id6 unmodified linessequence: stringsplits:- name: trainnum_bytes: 705477num_examples: 407download_size: 1010305dataset_size: 705477- config_name: pythonfeatures:- name: id6 unmodified linessequence: stringsplits:- name: trainnum_bytes: 2566353num_examples: 1264download_size: 3577929dataset_size: 2566353- config_name: rubyfeatures:- name: id6 unmodified linessequence: stringsplits:- name: trainnum_bytes: 48946num_examples: 38download_size: 67675dataset_size: 48946config_names:- go- java- javascript- php- python- ruby---# Dataset Card for "code_x_glue_cc_cloze_testing_maxmin"19 unmodified lines202122232425262728293031327 unmodified lines404142434445464748496 unmodified lines565758596061626364656 unmodified lines727374757677787980816 unmodified lines888990919293949596976 unmodified lines1041051061071081091101111121136 unmodified lines12012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315419 unmodified linestask_ids:- slot-fillingpretty_name: CodeXGlueCcClozeTestingMaxminconfig_names:- go- java- javascript- php- python- rubydataset_info:- config_name: gofeatures:7 unmodified linessequence: stringsplits:- name: trainnum_bytes: 204977num_examples: 152download_size: 68965dataset_size: 204977- config_name: javafeatures:- name: id6 unmodified linessequence: stringsplits:- name: trainnum_bytes: 785734num_examples: 482download_size: 250672dataset_size: 785734- config_name: javascriptfeatures:- name: id6 unmodified linessequence: stringsplits:- name: trainnum_bytes: 594327num_examples: 272download_size: 188271dataset_size: 594327- config_name: phpfeatures:- name: id6 unmodified linessequence: stringsplits:- name: trainnum_bytes: 705457num_examples: 407download_size: 211107dataset_size: 705457- config_name: pythonfeatures:- name: id6 unmodified linessequence: stringsplits:- name: trainnum_bytes: 2566333num_examples: 1264download_size: 885488dataset_size: 2566333- config_name: rubyfeatures:- name: id6 unmodified linessequence: stringsplits:- name: trainnum_bytes: 48926num_examples: 38download_size: 22528dataset_size: 48926configs:- config_name: godata_files:- split: trainpath: go/train-*- config_name: javadata_files:- split: trainpath: java/train-*- config_name: javascriptdata_files:- split: trainpath: javascript/train-*- config_name: phpdata_files:- split: trainpath: php/train-*- config_name: pythondata_files:- split: trainpath: python/train-*- config_name: rubydata_files:- split: trainpath: ruby/train-*---# Dataset Card for "code_x_glue_cc_cloze_testing_maxmin"
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283import jsonfrom typing import List
import datasets
from .common import Childfrom .generated_definitions import DEFINITIONS
_DESCRIPTION = """Cloze tests are widely adopted in Natural Languages Processing to evaluate the performance of the trained language models. The task is aimed to predict the answers for the blank with the context of the blank, which can be formulated as a multi-choice classification problem.Here we present the two cloze testing datasets in code domain with six different programming languages: ClozeTest-maxmin and ClozeTest-all. Each instance in the dataset contains a masked code function, its docstring and the target word.The only difference between ClozeTest-maxmin and ClozeTest-all is their selected words sets, where ClozeTest-maxmin only contains two words while ClozeTest-all contains 930 words."""
_CITATION = """@article{CodeXGLUE,title={CodeXGLUE: An Open Challenge for Code Intelligence},journal={arXiv},year={2020},}@article{feng2020codebert,title={CodeBERT: A Pre-Trained Model for Programming and Natural Languages},author={Feng, Zhangyin and Guo, Daya and Tang, Duyu and Duan, Nan and Feng, Xiaocheng and Gong, Ming and Shou, Linjun and Qin, Bing and Liu, Ting and Jiang, Daxin and others},journal={arXiv preprint arXiv:2002.08155},year={2020}}@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 CodeXGlueCcClozeTestingImpl(Child): _DESCRIPTION = _DESCRIPTION _CITATION = _CITATION
_FEATURES = { "id": datasets.Value("int32"), # Index of the sample "idx": datasets.Value("string"), # Original index in the dataset "nl_tokens": datasets.features.Sequence(datasets.Value("string")), # Natural language tokens "pl_tokens": datasets.features.Sequence(datasets.Value("string")), # Programming language tokens }
def generate_urls(self, split_name): yield "data", "clozeTest.json"
def _generate_examples(self, split_name, file_paths): with open(file_paths["data"], encoding="utf-8") as f: j = json.load(f) index = 0 for entry in j: yield index, dict( id=index, idx=entry["idx"], nl_tokens=entry["nl_tokens"], pl_tokens=entry["pl_tokens"] ) index += 1
CLASS_MAPPING = { "CodeXGlueCcClozeTestingMaxmin": CodeXGlueCcClozeTestingImpl,}
class CodeXGlueCcClozeTestingMaxmin(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": "CodeXGlueCcClozeTestingMaxmin", "dataset_type": "Code-Code", "description": "CodeXGLUE ClozeTesting-maxmin dataset, available at https://github.com/microsoft/CodeXGLUE/tree/main/Code-Code/ClozeTesting-maxmin", "dir_name": "ClozeTesting-maxmin", "name": "go", "parameters": {"language": "go"}, "project_url": "https://github.com/madlag/CodeXGLUE/tree/main/Code-Code/ClozeTesting-maxmin", "raw_url": "https://raw.githubusercontent.com/madlag/CodeXGLUE/main/Code-Code/ClozeTesting-maxmin/data/cloze-maxmin/go", "sizes": {"train": 152}, }, "java": { "class_name": "CodeXGlueCcClozeTestingMaxmin", "dataset_type": "Code-Code", "description": "CodeXGLUE ClozeTesting-maxmin dataset, available at https://github.com/microsoft/CodeXGLUE/tree/main/Code-Code/ClozeTesting-maxmin", "dir_name": "ClozeTesting-maxmin", "name": "java", "parameters": {"language": "java"}, "project_url": "https://github.com/madlag/CodeXGLUE/tree/main/Code-Code/ClozeTesting-maxmin", "raw_url": "https://raw.githubusercontent.com/madlag/CodeXGLUE/main/Code-Code/ClozeTesting-maxmin/data/cloze-maxmin/java", "sizes": {"train": 482}, }, "javascript": { "class_name": "CodeXGlueCcClozeTestingMaxmin", "dataset_type": "Code-Code", "description": "CodeXGLUE ClozeTesting-maxmin dataset, available at https://github.com/microsoft/CodeXGLUE/tree/main/Code-Code/ClozeTesting-maxmin", "dir_name": "ClozeTesting-maxmin", "name": "javascript", "parameters": {"language": "javascript"}, "project_url": "https://github.com/madlag/CodeXGLUE/tree/main/Code-Code/ClozeTesting-maxmin", "raw_url": "https://raw.githubusercontent.com/madlag/CodeXGLUE/main/Code-Code/ClozeTesting-maxmin/data/cloze-maxmin/javascript", "sizes": {"train": 272}, }, "php": { "class_name": "CodeXGlueCcClozeTestingMaxmin", "dataset_type": "Code-Code", "description": "CodeXGLUE ClozeTesting-maxmin dataset, available at https://github.com/microsoft/CodeXGLUE/tree/main/Code-Code/ClozeTesting-maxmin", "dir_name": "ClozeTesting-maxmin", "name": "php", "parameters": {"language": "php"}, "project_url": "https://github.com/madlag/CodeXGLUE/tree/main/Code-Code/ClozeTesting-maxmin", "raw_url": "https://raw.githubusercontent.com/madlag/CodeXGLUE/main/Code-Code/ClozeTesting-maxmin/data/cloze-maxmin/php", "sizes": {"train": 407}, }, "python": { "class_name": "CodeXGlueCcClozeTestingMaxmin", "dataset_type": "Code-Code", "description": "CodeXGLUE ClozeTesting-maxmin dataset, available at https://github.com/microsoft/CodeXGLUE/tree/main/Code-Code/ClozeTesting-maxmin", "dir_name": "ClozeTesting-maxmin", "name": "python", "parameters": {"language": "python"}, "project_url": "https://github.com/madlag/CodeXGLUE/tree/main/Code-Code/ClozeTesting-maxmin", "raw_url": "https://raw.githubusercontent.com/madlag/CodeXGLUE/main/Code-Code/ClozeTesting-maxmin/data/cloze-maxmin/python", "sizes": {"train": 1264}, }, "ruby": { "class_name": "CodeXGlueCcClozeTestingMaxmin", "dataset_type": "Code-Code", "description": "CodeXGLUE ClozeTesting-maxmin dataset, available at https://github.com/microsoft/CodeXGLUE/tree/main/Code-Code/ClozeTesting-maxmin", "dir_name": "ClozeTesting-maxmin", "name": "ruby", "parameters": {"language": "ruby"}, "project_url": "https://github.com/madlag/CodeXGLUE/tree/main/Code-Code/ClozeTesting-maxmin", "raw_url": "https://raw.githubusercontent.com/madlag/CodeXGLUE/main/Code-Code/ClozeTesting-maxmin/data/cloze-maxmin/ruby", "sizes": {"train": 38}, },}123version https://git-lfs.github.com/spec/v1oid sha256:cf8765045260eee29183365baa6da5d18aded91b711aaba89208cd0d9d50f7f6size 68965123version https://git-lfs.github.com/spec/v1oid sha256:fe4c876b680edb4d5091bec3738545ce6304313bb46598641e2f6511fb065a83size 250672123version https://git-lfs.github.com/spec/v1oid sha256:8df5849c7da7a844103d2089c55958c786d1cb52736dc8e94aef50d5b6a81501size 188271123version https://git-lfs.github.com/spec/v1oid sha256:0c722363179a83e4d8ad2943fefe2c76ef899e99c781f295ca071462e15a2ef3size 211107123version https://git-lfs.github.com/spec/v1oid sha256:0a6995187154d7c85f41a6bececd2d83f32fabf3e9fc8f9de0aeafe5b79e094fsize 885488123version https://git-lfs.github.com/spec/v1oid sha256:c2d4166f5c7006597aafb40a07a1b549c503b69f1fc08b487afba39b4976de64size 22528README.md+50-25
code_x_glue_cc_cloze_testing_maxmin.pyDeleted-83
common.pyDeleted-75
generated_definitions.pyDeleted-68
go/train-00000-of-00001.parquetAdded+3
java/train-00000-of-00001.parquetAdded+3
javascript/train-00000-of-00001.parquetAdded+3
php/train-00000-of-00001.parquetAdded+3
python/train-00000-of-00001.parquetAdded+3
ruby/train-00000-of-00001.parquetAdded+3