Commit ·
6c83f87
1
Parent(s): 3dcf6eb
Update parquet files
Browse filesFiles changed (11)
- README.mdDeleted-241
- code_x_glue_cc_code_completion_token.pyDeleted-216
- common.pyDeleted-75
- dataset_infos.jsonDeleted-1
- generated_definitions.pyDeleted-24
- java/code_x_glue_cc_code_completion_token-test.parquetAdded+3
- java/code_x_glue_cc_code_completion_token-train.parquetAdded+3
- java/code_x_glue_cc_code_completion_token-validation.parquetAdded+3
- python/code_x_glue_cc_code_completion_token-test.parquetAdded+3
- python/code_x_glue_cc_code_completion_token-train-00000-of-00002.parquetAdded+3
- python/code_x_glue_cc_code_completion_token-train-00001-of-00002.parquetAdded+3
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241---annotations_creators:- foundlanguage_creators:- foundlanguage:- codelicense:- c-udamultilinguality:- monolingualsize_categories:- 10K<n<100Ksource_datasets:- originaltask_categories:- text-generation- fill-masktask_ids:- language-modeling- masked-language-modelingpretty_name: CodeXGlueCcCodeCompletionTokendataset_info:- config_name: java features: - name: id dtype: int32 - name: code sequence: string splits: - name: train num_bytes: 128312061 num_examples: 12934 - name: validation num_bytes: 30259174 num_examples: 7189 - name: test num_bytes: 43027956 num_examples: 8268 download_size: 126856519 dataset_size: 201599191- config_name: python features: - name: id dtype: int32 - name: path dtype: string - name: code sequence: string splits: - name: train num_bytes: 684319575 num_examples: 100000 - name: test num_bytes: 333978088 num_examples: 50000 download_size: 199067128 dataset_size: 1018297663---# Dataset Card for "code_x_glue_cc_code_completion_token"
## Table of Contents- [Dataset Description](#dataset-description) - [Dataset Summary](#dataset-summary) - [Supported Tasks and Leaderboards](#supported-tasks) - [Languages](#languages)- [Dataset Structure](#dataset-structure) - [Data Instances](#data-instances) - [Data Fields](#data-fields) - [Data Splits](#data-splits-sample-size)- [Dataset Creation](#dataset-creation) - [Curation Rationale](#curation-rationale) - [Source Data](#source-data) - [Annotations](#annotations) - [Personal and Sensitive Information](#personal-and-sensitive-information)- [Considerations for Using the Data](#considerations-for-using-the-data) - [Social Impact of Dataset](#social-impact-of-dataset) - [Discussion of Biases](#discussion-of-biases) - [Other Known Limitations](#other-known-limitations)- [Additional Information](#additional-information) - [Dataset Curators](#dataset-curators) - [Licensing Information](#licensing-information) - [Citation Information](#citation-information) - [Contributions](#contributions)
## Dataset Description
- **Homepage:** https://github.com/microsoft/CodeXGLUE/tree/main/Code-Code/CodeCompletion-token
### Dataset Summary
CodeXGLUE CodeCompletion-token dataset, available at https://github.com/microsoft/CodeXGLUE/tree/main/Code-Code/CodeCompletion-token
Predict next code token given context of previous tokens. Models are evaluated by token level accuracy. Code completion is a one of the most widely used features in software development through IDEs. An effective code completion tool could improve software developers' productivity. We provide code completion evaluation tasks in two granularities -- token level and line level. Here we introduce token level code completion. Token level task is analogous to language modeling. Models should have be able to predict the next token in arbitary types.
### Supported Tasks and Leaderboards
- `language-modeling`: The dataset can be used to train a model for completing single code tokens.
### Languages
- Java **programming** language- Python **programming** language
## Dataset Structure
### Data Instances
#### java
An example of 'test' looks as follows.```{ "code": ["<s>", "package", "org", ".", "vaadin", ".", "teemu", ".", "clara", ".", "demo", ";", "import", "java", ".", "io", ".", "BufferedReader", ";", "import", "java", ".", "io", ".", "ByteArrayInputStream", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "InputStreamReader", ";", "import", "org", ".", "vaadin", ".", "teemu", ".", "clara", ".", "Clara", ";", "import", "org", ".", "vaadin", ".", "teemu", ".", "clara", ".", "inflater", ".", "LayoutInflaterException", ";", "import", "com", ".", "vaadin", ".", "Application", ";", "import", "com", ".", "vaadin", ".", "terminal", ".", "ThemeResource", ";", "import", "com", ".", "vaadin", ".", "ui", ".", "Button", ";", "import", "com", ".", "vaadin", ".", "ui", ".", "Button", ".", "ClickEvent", ";", "import", "com", ".", "vaadin", ".", "ui", ".", "Component", ";", "import", "com", ".", "vaadin", ".", "ui", ".", "Embedded", ";", "import", "com", ".", "vaadin", ".", "ui", ".", "HorizontalLayout", ";", "import", "com", ".", "vaadin", ".", "ui", ".", "HorizontalSplitPanel", ";", "import", "com", ".", "vaadin", ".", "ui", ".", "TextArea", ";", "import", "com", ".", "vaadin", ".", "ui", ".", "VerticalLayout", ";", "import", "com", ".", "vaadin", ".", "ui", ".", "Window", ";", "import", "com", ".", "vaadin", ".", "ui", ".", "Window", ".", "Notification", ";", "@", "SuppressWarnings", "(", "\"serial\"", ")", "public", "class", "DemoApplication", "extends", "Application", "{", "private", "DemoController", "controller", ";", "private", "TextArea", "xmlArea", ";", "private", "HorizontalSplitPanel", "split", "=", "new", "HorizontalSplitPanel", "(", ")", ";", "private", "Window", "mainWindow", ";", "@", "Override", "public", "void", "init", "(", ")", "{", "setTheme", "(", "\"clara\"", ")", ";", "setMainWindow", "(", "mainWindow", "=", "new", "Window", "(", ")", ")", ";", "controller", "=", "new", "DemoController", "(", "mainWindow", ")", ";", "mainWindow", ".", "setContent", "(", "split", ")", ";", "VerticalLayout", "editor", "=", "new", "VerticalLayout", "(", ")", ";", "editor", ".", "setSpacing", "(", "true", ")", ";", "editor", ".", "setMargin", "(", "false", ",", "false", ",", "false", ",", "true", ")", ";", "editor", ".", "setHeight", "(", "\"100%\"", ")", ";", "editor", ".", "addComponent", "(", "xmlArea", "=", "createXmlArea", "(", ")", ")", ";", "editor", ".", "setExpandRatio", "(", "xmlArea", ",", "1.0f", ")", ";", "editor", ".", "addComponent", "(", "createUpdateButton", "(", ")", ")", ";", "HorizontalLayout", "wrapper", "=", "new", "HorizontalLayout", "(", ")", ";", "wrapper", ".", "setMargin", "(", "true", ")", ";", "wrapper", ".", "setSizeFull", "(", ")", ";", "wrapper", ".", "addComponent", "(", "createLogo", "(", ")", ")", ";", "wrapper", ".", "addComponent", "(", "editor", ")", ";", "wrapper", ".", "setExpandRatio", "(", "editor", ",", "1.0f", ")", ";", "split", ".", "setFirstComponent", "(", "wrapper", ")", ";", "updateLayout", "(", ")", ";", "}", "private", "Component", "createLogo", "(", ")", "{", "Embedded", "logo", "=", "new", "Embedded", "(", "null", ",", "new", "ThemeResource", "(", "\"\"", ")", ")", ";", "logo", ".", "setHeight", "(", "\"90px\"", ")", ";", "logo", ".", "setWidth", "(", "\"90px\"", ")", ";", "return", "logo", ";", "}", "private", "TextArea", "createXmlArea", "(", ")", "{", "TextArea", "area", "=", "new", "TextArea", "(", ")", ";", "area", ".", "setStyleName", "(", "\"xml-area\"", ")", ";", "area", ".", "setSizeFull", "(", ")", ";", "area", ".", "setValue", "(", "readStartingPoint", "(", ")", ")", ";", "return", "area", ";", "}", "private", "Button", "createUpdateButton", "(", ")", "{", "return", "new", "Button", "(", "\"Update\"", ",", "new", "Button", ".", "ClickListener", "(", ")", "{", "public", "void", "buttonClick", "(", "ClickEvent", "event", ")", "{", "updateLayout", "(", ")", ";", "}", "}", ")", ";", "}", "private", "String", "readStartingPoint", "(", ")", "{", "BufferedReader", "reader", "=", "null", ";", "try", "{", "reader", "=", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "getClass", "(", ")", ".", "getClassLoader", "(", ")", ".", "getResourceAsStream", "(", "\"\"", ")", ")", ")", ";", "StringBuilder", "xml", "=", "new", "StringBuilder", "(", ")", ";", "String", "line", ";", "while", "(", "(", "line", "=", "reader", ".", "readLine", "(", ")", ")", "!=", "null", ")", "{", "xml", ".", "append", "(", "line", ")", ";", "xml", ".", "append", "(", "\"n\"", ")", ";", "}", "return", "xml", ".", "toString", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "finally", "{", "if", "(", "reader", "!=", "null", ")", "{", "try", "{", "reader", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "}", "return", "null", ";", "}", "private", "void", "updateLayout", "(", ")", "{", "try", "{", "Component", "c", "=", "Clara", ".", "create", "(", "new", "ByteArrayInputStream", "(", "xmlArea", ".", "getValue", "(", ")", ".", "toString", "(", ")", ".", "getBytes", "(", ")", ")", ",", "controller", ")", ";", "split", ".", "replaceComponent", "(", "split", ".", "getSecondComponent", "(", ")", ",", "c", ")", ";", "}", "catch", "(", "LayoutInflaterException", "e", ")", "{", "mainWindow", ".", "showNotification", "(", "e", ".", "getMessage", "(", ")", ",", "Notification", ".", "TYPE_ERROR_MESSAGE", ")", ";", "}", "}", "}", "</s>"], "id": 0}```
#### python
An example of 'train' looks as follows.```{ "code": ["<s>", "from", "bootstrap", "import", "Bootstrap", "<EOL>", "from", "fund", "import", "InstantPaymentNotificationHandler", "<EOL>", "from", "fund", "import", "ThankYouHandler", "<EOL>", "from", "view", "import", "*", "<EOL>", "mapping", "=", "[", "(", "<EOL>", "r'/'", ",", "<EOL>", "Index", "<EOL>", ")", ",", "(", "<EOL>", "r'/ipn'", ",", "<EOL>", "InstantPaymentNotificationHandler", "<EOL>", ")", ",", "(", "<EOL>", "r'/thank-you'", ",", "<EOL>", "ThankYouHandler", "<EOL>", ")", ",", "(", "<EOL>", "r'/about\\/?'", ",", "<EOL>", "About", "<EOL>", ")", ",", "(", "<EOL>", "r'/guide\\/?'", ",", "<EOL>", "Guide", "<EOL>", ")", ",", "(", "<EOL>", "r''", ",", "<EOL>", "Download", "<EOL>", ")", ",", "(", "<EOL>", "r''", ",", "<EOL>", "Standards", "<EOL>", ")", ",", "(", "<EOL>", "r'/community\\/?'", ",", "<EOL>", "Community", "<EOL>", ")", ",", "(", "<EOL>", "r'/news\\/?'", ",", "<EOL>", "News", "<EOL>", ")", ",", "(", "<EOL>", "r'/support\\/?'", ",", "<EOL>", "Support", "<EOL>", ")", ",", "(", "<EOL>", "r'/contact\\/?'", ",", "<EOL>", "Contact", "<EOL>", ")", ",", "(", "<EOL>", "r'/press\\/?'", ",", "<EOL>", "Press", "<EOL>", ")", ",", "(", "<EOL>", "r'/legal/terms'", ",", "<EOL>", "Terms", "<EOL>", ")", ",", "(", "<EOL>", "r'/library\\/?'", ",", "<EOL>", "Library", "<EOL>", ")", ",", "(", "<EOL>", "r''", ",", "<EOL>", "Library", "<EOL>", ")", ",", "(", "<EOL>", "r''", ",", "<EOL>", "Library", "<EOL>", ")", ",", "(", "<EOL>", "r''", ",", "<EOL>", "Users", "<EOL>", ")", ",", "(", "<EOL>", "r''", ",", "<EOL>", "User", "<EOL>", ")", ",", "(", "<EOL>", "r''", ",", "<EOL>", "Design", "<EOL>", ")", ",", "(", "<EOL>", "r''", ",", "<EOL>", "Design", "<EOL>", ")", ",", "(", "<EOL>", "r''", ",", "<EOL>", "Design", "<EOL>", ")", ",", "(", "<EOL>", "r''", ",", "<EOL>", "Design", "<EOL>", ")", ",", "(", "<EOL>", "r''", ",", "<EOL>", "Design", "<EOL>", ")", ",", "(", "<EOL>", "r''", ",", "<EOL>", "RedirectSuccess", "<EOL>", ")", ",", "(", "<EOL>", "r''", ",", "<EOL>", "RedirectError", "<EOL>", ")", ",", "(", "<EOL>", "r''", ",", "<EOL>", "RedirectAfterDelete", "<EOL>", ")", ",", "(", "<EOL>", "r''", ",", "<EOL>", "Moderate", "<EOL>", ")", ",", "(", "<EOL>", "r''", ",", "<EOL>", "Bootstrap", "<EOL>", ")", ",", "(", "<EOL>", "r'/activity'", ",", "<EOL>", "ActivityScreen", "<EOL>", ")", ",", "(", "<EOL>", "r'/txns'", ",", "<EOL>", "TxnList", "<EOL>", ")", ",", "(", "<EOL>", "r''", ",", "<EOL>", "Base64Blob", "<EOL>", ")", ",", "(", "<EOL>", "r''", ",", "<EOL>", "Base64Blob", "<EOL>", ")", ",", "(", "<EOL>", "r''", ",", "<EOL>", "MessageStrings", "<EOL>", ")", ",", "(", "<EOL>", "r'/.*'", ",", "<EOL>", "NotFound", "<EOL>", ")", "<EOL>", "]", "</s>"], "id": 0, "path": "00/wikihouse/urls.py\n"}```
### Data Fields
In the following each data field in go is explained for each config. The data fields are the same among all splits.
#### java
|field name| type | description ||----------|----------------|--------------------||id |int32 | Index of the sample||code |Sequence[string]| Code Tokens |
#### python
|field name| type | description ||----------|----------------|-----------------------------||id |int32 | Index of the sample ||path |string | Original path in the dataset||code |Sequence[string]| Code Tokens |
### Data Splits
#### java
| |train|validation|test||----|----:|---------:|---:||java|12934| 7189|8268|
#### python
| |train |test ||------|-----:|----:||python|100000|50000|
## Dataset Creation
### Curation Rationale
[More Information Needed]
### Source Data
#### Initial Data Collection and Normalization
[More Information Needed]
#### Who are the source language producers?
[More Information Needed]
### Annotations
#### Annotation process
[More Information Needed]
#### Who are the annotators?
[More Information Needed]
### Personal and Sensitive Information
[More Information Needed]
## Considerations for Using the Data
### Social Impact of Dataset
[More Information Needed]
### Discussion of Biases
[More Information Needed]
### Other Known Limitations
[More Information Needed]
## Additional Information
### Dataset Curators
https://github.com/microsoft, https://github.com/madlag
### Licensing Information
Computational Use of Data Agreement (C-UDA) License.
### Citation Information
```@article{raychev2016probabilistic, title={Probabilistic Model for Code with Decision Trees}, author={Raychev, Veselin and Bielik, Pavol and Vechev, Martin}, journal={ACM SIGPLAN Notices}, pages={731--747}, year={2016}, publisher={ACM New York, NY, USA} } @inproceedings{allamanis2013mining, title={Mining Source Code Repositories at Massive Scale using Language Modeling}, author={Allamanis, Miltiadis and Sutton, Charles}, booktitle={2013 10th Working Conference on Mining Software Repositories (MSR)}, pages={207--216}, year={2013}, organization={IEEE} }```
### Contributions
Thanks to @madlag (and partly also @ncoop57) for adding this dataset.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216import osimport os.pathfrom typing import List
import datasets
from .common import Childfrom .generated_definitions import DEFINITIONS
_DESCRIPTION = """Predict next code token given context of previous tokens. Models are evaluated by token level accuracy.Code completion is a one of the most widely used features in software development through IDEs. An effective code completion tool could improve software developers' productivity. We provide code completion evaluation tasks in two granularities -- token level and line level. Here we introduce token level code completion. Token level task is analogous to language modeling. Models should have be able to predict the next token in arbitary types."""
_CITATION = """@article{raychev2016probabilistic, title={Probabilistic Model for Code with Decision Trees}, author={Raychev, Veselin and Bielik, Pavol and Vechev, Martin}, journal={ACM SIGPLAN Notices}, pages={731--747}, year={2016}, publisher={ACM New York, NY, USA}}@inproceedings{allamanis2013mining, title={Mining Source Code Repositories at Massive Scale using Language Modeling}, author={Allamanis, Miltiadis and Sutton, Charles}, booktitle={2013 10th Working Conference on Mining Software Repositories (MSR)}, pages={207--216}, year={2013}, organization={IEEE}}"""
class CodeXGlueCcCodeCompletionTokenImpl(Child): _DESCRIPTION = _DESCRIPTION _CITATION = _CITATION
class CodeXGlueCcCodeCompletionTokenJavaImpl(CodeXGlueCcCodeCompletionTokenImpl): SPLITS = { "training": datasets.Split.TRAIN, "validation": datasets.Split.VALIDATION, "test": datasets.Split.TEST, }
_FEATURES = { "id": datasets.Value("int32"), # Index of the sample "code": datasets.features.Sequence(datasets.Value("string")), # Code Tokens }
def generate_urls(self, split_name): language = self.info["parameters"]["language"] if language != "java": raise RuntimeError(f"Unknown language {language}: should be java.")
yield "data", f"https://zenodo.org/record/3628665/files/java_{split_name}_pre"
def _generate_examples(self, split_name, file_paths): with open(file_paths["data"], encoding="utf-8") as f: for idx, line in enumerate(f): new_data = [] for token in line.strip().split(): if len(token) > 100: continue new_data.append(token) entry = dict(id=idx, code=new_data) yield idx, entry
class CodeXGlueCcCodeCompletionTokenPythonImpl(CodeXGlueCcCodeCompletionTokenImpl): SPLITS = {"train": datasets.Split.TRAIN, "test": datasets.Split.TEST}
_FEATURES = { "id": datasets.Value("int32"), # Index of the sample "path": datasets.Value("string"), # Original path in the dataset "code": datasets.features.Sequence(datasets.Value("string")), # Code Tokens }
PYTHON_FILE_MAPPING = dict(train="python100k_train.txt", test="python50k_eval.txt")
def generate_urls(self, split_name): language = self.info["parameters"]["language"] if language != "python": raise RuntimeError(f"Unknown language {language}")
yield "data", "http://files.srl.inf.ethz.ch/data/py150_files.tar.gz"
def process_string(self, token): # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import re
str_quote_options = ["'''", '"""', "'", '"'] start_quote = "" end_quote = "" qualifier_regex = r"^[a-z]+" qualifier_match = re.search(qualifier_regex, token) # string qualifiers like 'r' for regex, 'f' for formatted string, 'b' for bytes, 'u' for unicode, etc (or combination of them) qualifier = "" if not qualifier_match else qualifier_match[0] # token string without qualifiers token_string = re.sub(qualifier_regex, "", token) # string literal without quotes str_lit = token_string for q in str_quote_options: if token_string.startswith(q): start_quote = q str_lit = str_lit[len(q) :] if token_string.endswith(q): end_quote = q str_lit = str_lit[: -len(q)] break if start_quote in str_quote_options[:2]: return "" return ( f"{qualifier}{start_quote}{str_lit}{end_quote}" if len(str_lit) < 15 and "\n" not in str_lit and "</s>" not in str_lit and "<s>" not in str_lit and "<pad>" not in str_lit and "<EOL>" not in str_lit else f"{qualifier}{start_quote}{end_quote}" )
def py_tokenize(self, base_dir, file_name): # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from io import BytesIO from tokenize import COMMENT, ENCODING, ENDMARKER, INDENT, NEWLINE, NL, NUMBER, STRING, tokenize
file_paths = open(os.path.join(base_dir, file_name), encoding="utf-8").readlines() for ct, path in enumerate(file_paths): try: code = open(os.path.join(base_dir, path.strip()), encoding="utf-8").read() token_gen = tokenize(BytesIO(bytes(code, "utf8")).readline) out_tokens = [] prev_eol = False for toknum, tokval, _, _, _ in token_gen: tokval = " ".join(tokval.split()) if len(tokval) > 100: continue if toknum == STRING: add_token = self.process_string(tokval) if len(add_token) > 0: out_tokens.append(add_token) prev_eol = False elif toknum == NUMBER: if len(tokval) < 50: out_tokens.append(tokval) prev_eol = False elif toknum in [NEWLINE, NL]: if not prev_eol: out_tokens.append("<EOL>") prev_eol = True elif toknum in [COMMENT, INDENT, ENCODING, ENDMARKER] or len(tokval) == 0: continue else: out_tokens.append(tokval) prev_eol = False if out_tokens[0] == "<EOL>": out_tokens = out_tokens[1:] if out_tokens[-1] == "<EOL>": out_tokens = out_tokens[:-1] except Exception: out_tokens = [] out_tokens = ["<s>"] + out_tokens + ["</s>"] yield path, out_tokens
def _generate_examples(self, split_name, file_paths): base_dir = file_paths["data"] filename = self.PYTHON_FILE_MAPPING[split_name]
data_dir = os.path.join(base_dir, "data") if not os.path.exists(data_dir): import gzip import tarfile
gzip_filename = os.path.join(base_dir, "data.tar.gz") with gzip.open(gzip_filename, "rb") as gzip_file: t = tarfile.TarFile(fileobj=gzip_file) t.extractall(path=base_dir)
idx = 0 for entry in self.py_tokenize(base_dir=base_dir, file_name=filename): path, out_tokens = entry path = path[len("data/") :] yield idx, dict(id=idx, path=path, code=out_tokens) idx += 1
CLASS_MAPPING = { "CodeXGlueCcCodeCompletionTokenJava": CodeXGlueCcCodeCompletionTokenJavaImpl, "CodeXGlueCcCodeCompletionTokenPython": CodeXGlueCcCodeCompletionTokenPythonImpl,}
class CodeXGlueCcCodeCompletionToken(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, }1{"java": {"description": "CodeXGLUE CodeCompletion-token dataset, available at https://github.com/microsoft/CodeXGLUE/tree/main/Code-Code/CodeCompletion-token\n\nPredict next code token given context of previous tokens. Models are evaluated by token level accuracy.\nCode completion is a one of the most widely used features in software development through IDEs. An effective code completion tool could improve software developers' productivity. We provide code completion evaluation tasks in two granularities -- token level and line level. Here we introduce token level code completion. Token level task is analogous to language modeling. Models should have be able to predict the next token in arbitary types.\n", "citation": "@article{raychev2016probabilistic,\n title={Probabilistic Model for Code with Decision Trees},\n author={Raychev, Veselin and Bielik, Pavol and Vechev, Martin},\n journal={ACM SIGPLAN Notices},\n pages={731--747},\n year={2016},\n publisher={ACM New York, NY, USA}\n}\n@inproceedings{allamanis2013mining,\n title={Mining Source Code Repositories at Massive Scale using Language Modeling},\n author={Allamanis, Miltiadis and Sutton, Charles},\n booktitle={2013 10th Working Conference on Mining Software Repositories (MSR)},\n pages={207--216},\n year={2013},\n organization={IEEE}\n}", "homepage": "https://github.com/madlag/CodeXGLUE/tree/main/Code-Code/CodeCompletion-token", "license": "", "features": {"id": {"dtype": "int32", "id": null, "_type": "Value"}, "code": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "code_x_glue_cc_code_completion_token", "config_name": "java", "version": {"version_str": "0.0.0", "description": null, "major": 0, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 128312061, "num_examples": 12934, "dataset_name": "code_x_glue_cc_code_completion_token"}, "validation": {"name": "validation", "num_bytes": 30259174, "num_examples": 7189, "dataset_name": "code_x_glue_cc_code_completion_token"}, "test": {"name": "test", "num_bytes": 43027956, "num_examples": 8268, "dataset_name": "code_x_glue_cc_code_completion_token"}}, "download_checksums": {"https://zenodo.org/record/3628665/files/java_training_pre": {"num_bytes": 81051708, "checksum": "676295d2756adcac22e213fbc3ea0f50669a0d152e9497e23a2929e2e2124905"}, "https://zenodo.org/record/3628665/files/java_validation_pre": {"num_bytes": 18835141, "checksum": "0c58a97d96aa7435396581ee5efbb93c0e74a545ba5f795f878098a6e59ab8b3"}, "https://zenodo.org/record/3628665/files/java_test_pre": {"num_bytes": 26969670, "checksum": "a88cd5c91c2ed23a928528bef3535f4fc8db1359975447211f2b13926cc38d9d"}}, "download_size": 126856519, "post_processing_size": null, "dataset_size": 201599191, "size_in_bytes": 328455710}, "python": {"description": "CodeXGLUE CodeCompletion-token dataset, available at https://github.com/microsoft/CodeXGLUE/tree/main/Code-Code/CodeCompletion-token\n\nPredict next code token given context of previous tokens. Models are evaluated by token level accuracy.\nCode completion is a one of the most widely used features in software development through IDEs. An effective code completion tool could improve software developers' productivity. We provide code completion evaluation tasks in two granularities -- token level and line level. Here we introduce token level code completion. Token level task is analogous to language modeling. Models should have be able to predict the next token in arbitary types.\n", "citation": "@article{raychev2016probabilistic,\n title={Probabilistic Model for Code with Decision Trees},\n author={Raychev, Veselin and Bielik, Pavol and Vechev, Martin},\n journal={ACM SIGPLAN Notices},\n pages={731--747},\n year={2016},\n publisher={ACM New York, NY, USA}\n}\n@inproceedings{allamanis2013mining,\n title={Mining Source Code Repositories at Massive Scale using Language Modeling},\n author={Allamanis, Miltiadis and Sutton, Charles},\n booktitle={2013 10th Working Conference on Mining Software Repositories (MSR)},\n pages={207--216},\n year={2013},\n organization={IEEE}\n}", "homepage": "https://github.com/madlag/CodeXGLUE/tree/main/Code-Code/CodeCompletion-token", "license": "", "features": {"id": {"dtype": "int32", "id": null, "_type": "Value"}, "path": {"dtype": "string", "id": null, "_type": "Value"}, "code": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "code_x_glue_cc_code_completion_token", "config_name": "python", "version": {"version_str": "0.0.0", "description": null, "major": 0, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 684319575, "num_examples": 100000, "dataset_name": "code_x_glue_cc_code_completion_token"}, "test": {"name": "test", "num_bytes": 333978088, "num_examples": 50000, "dataset_name": "code_x_glue_cc_code_completion_token"}}, "download_checksums": {"http://files.srl.inf.ethz.ch/data/py150_files.tar.gz": {"num_bytes": 199067128, "checksum": "73be7f7a78e549845cf80cf779a3bcc3a9cf351ff7017e07b89e8d1c82b8d389"}}, "download_size": 199067128, "post_processing_size": null, "dataset_size": 1018297663, "size_in_bytes": 1217364791}}123456789101112131415161718192021222324DEFINITIONS = { "java": { "class_name": "CodeXGlueCcCodeCompletionTokenJava", "dataset_type": "Code-Code", "description": "CodeXGLUE CodeCompletion-token dataset, available at https://github.com/microsoft/CodeXGLUE/tree/main/Code-Code/CodeCompletion-token", "dir_name": "CodeCompletion-token", "name": "java", "parameters": {"language": "java", "original_language_name": "javaCorpus"}, "project_url": "https://github.com/madlag/CodeXGLUE/tree/main/Code-Code/CodeCompletion-token", "raw_url": "https://raw.githubusercontent.com/madlag/CodeXGLUE/main/Code-Code/CodeCompletion-token/dataset/javaCorpus", "sizes": {"test": 8268, "train": 12934, "validation": 7189}, }, "python": { "class_name": "CodeXGlueCcCodeCompletionTokenPython", "dataset_type": "Code-Code", "description": "CodeXGLUE CodeCompletion-token dataset, available at https://github.com/microsoft/CodeXGLUE/tree/main/Code-Code/CodeCompletion-token", "dir_name": "CodeCompletion-token", "name": "python", "parameters": {"language": "python", "original_language_name": "py150"}, "project_url": "https://github.com/madlag/CodeXGLUE/tree/main/Code-Code/CodeCompletion-token", "raw_url": "https://raw.githubusercontent.com/madlag/CodeXGLUE/main/Code-Code/CodeCompletion-token/dataset/py150", "sizes": {"test": 50000, "train": 100000}, },}123version https://git-lfs.github.com/spec/v1oid sha256:47ce850847e3dbe0ab9984950d48a7d0cee8b437cb16e0d6d07807309a384900size 6543102123version https://git-lfs.github.com/spec/v1oid sha256:10b2a03b75a24d51721cfd4414fd69de027791595ffb5fc3dae86f57b3b5b83fsize 19617198123version https://git-lfs.github.com/spec/v1oid sha256:239ecd0a7db218b352aa03724cc51065437a493cf8ced6939702370ae058683csize 5160036123version https://git-lfs.github.com/spec/v1oid sha256:8cda88487f319a193ad9eb0078d65a0fcd905c361f05ddf89a75eb4222bfa5c6size 69199820123version https://git-lfs.github.com/spec/v1oid sha256:0cb29c3005af01a3f599796494a82aed3aaeaa295577f99c4b755448bb62d956size 103864714123version https://git-lfs.github.com/spec/v1oid sha256:a5e8f43f8e9fb9688fbacf94ffc37d7b46c2dc650699a0065c89077080134794size 37078998README.mdDeleted-241
code_x_glue_cc_code_completion_token.pyDeleted-216
common.pyDeleted-75
dataset_infos.jsonDeleted-1
generated_definitions.pyDeleted-24
java/code_x_glue_cc_code_completion_token-test.parquetAdded+3
java/code_x_glue_cc_code_completion_token-train.parquetAdded+3
java/code_x_glue_cc_code_completion_token-validation.parquetAdded+3
python/code_x_glue_cc_code_completion_token-test.parquetAdded+3
python/code_x_glue_cc_code_completion_token-train-00000-of-00002.parquetAdded+3
python/code_x_glue_cc_code_completion_token-train-00001-of-00002.parquetAdded+3