Datasets:

Sub-tasks:
extractive-qa
Languages:
English
Multilinguality:
monolingual
Size Categories:
1M<n<10M
n<1K
Language Creators:
crowdsourced
Annotations Creators:
expert-generated
Source Datasets:
original
ArXiv:
Tags:
License:
system HF staff commited on
Commit
8c00753
0 Parent(s):

Update files from the datasets library (from 1.2.0)

Browse files

Release notes: https://github.com/huggingface/datasets/releases/tag/1.2.0

.gitattributes ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bin.* filter=lfs diff=lfs merge=lfs -text
5
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.model filter=lfs diff=lfs merge=lfs -text
12
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
13
+ *.onnx filter=lfs diff=lfs merge=lfs -text
14
+ *.ot filter=lfs diff=lfs merge=lfs -text
15
+ *.parquet filter=lfs diff=lfs merge=lfs -text
16
+ *.pb filter=lfs diff=lfs merge=lfs -text
17
+ *.pt filter=lfs diff=lfs merge=lfs -text
18
+ *.pth filter=lfs diff=lfs merge=lfs -text
19
+ *.rar filter=lfs diff=lfs merge=lfs -text
20
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
21
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
22
+ *.tflite filter=lfs diff=lfs merge=lfs -text
23
+ *.tgz filter=lfs diff=lfs merge=lfs -text
24
+ *.xz filter=lfs diff=lfs merge=lfs -text
25
+ *.zip filter=lfs diff=lfs merge=lfs -text
26
+ *.zstandard filter=lfs diff=lfs merge=lfs -text
27
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ annotations_creators:
3
+ - expert-generated
4
+ language_creators:
5
+ - crowdsourced
6
+ languages:
7
+ - en
8
+ licenses:
9
+ - cc-by-nc-4-0
10
+ multilinguality:
11
+ - monolingual
12
+ size_categories:
13
+ evaluation_dataset:
14
+ - n<1K
15
+ search_corpus:
16
+ - n>1M
17
+ source_datasets:
18
+ - original
19
+ task_categories:
20
+ - question-answering
21
+ task_ids:
22
+ evaluation_dataset:
23
+ - extractive-qa
24
+ search_corpus:
25
+ - extractive-qa
26
+ ---
27
+
28
+ # Dataset Card for Neural Code Search
29
+
30
+ ## Table of Contents
31
+ - [Dataset Description](#dataset-description)
32
+ - [Dataset Summary](#dataset-summary)
33
+ - [Supported Tasks](#supported-tasks-and-leaderboards)
34
+ - [Languages](#languages)
35
+ - [Dataset Structure](#dataset-structure)
36
+ - [Data Instances](#data-instances)
37
+ - [Data Fields](#data-instances)
38
+ - [Data Splits](#data-instances)
39
+ - [Dataset Creation](#dataset-creation)
40
+ - [Curation Rationale](#curation-rationale)
41
+ - [Source Data](#source-data)
42
+ - [Annotations](#annotations)
43
+ - [Personal and Sensitive Information](#personal-and-sensitive-information)
44
+ - [Considerations for Using the Data](#considerations-for-using-the-data)
45
+ - [Social Impact of Dataset](#social-impact-of-dataset)
46
+ - [Discussion of Biases](#discussion-of-biases)
47
+ - [Other Known Limitations](#other-known-limitations)
48
+ - [Additional Information](#additional-information)
49
+ - [Dataset Curators](#dataset-curators)
50
+ - [Licensing Information](#licensing-information)
51
+ - [Citation Information](#citation-information)
52
+
53
+ ## Dataset Description
54
+
55
+ - **Homepage:**
56
+ [facebookresearch
57
+ /
58
+ Neural-Code-Search-Evaluation-Dataset](https://github.com/facebookresearch/Neural-Code-Search-Evaluation-Dataset/tree/master/data)
59
+ - **Repository:**
60
+ [Github](https://github.com/facebookresearch/Neural-Code-Search-Evaluation-Dataset.git)
61
+ - **Paper:**
62
+ [arXiv](https://arxiv.org/pdf/1908.09804.pdf)
63
+
64
+ ### Dataset Summary
65
+
66
+ Neural-Code-Search-Evaluation-Dataset presents an evaluation dataset consisting of natural language query and code snippet pairs, with the hope that future work in this area can use this dataset as a common benchmark. We also provide the results of two code search models (NCS, UNIF) from recent work.
67
+
68
+ ### Supported Tasks and Leaderboards
69
+
70
+ [More Information Needed]
71
+
72
+ ### Languages
73
+
74
+ EN - English
75
+
76
+ ## Dataset Structure
77
+
78
+ ### Data Instances
79
+
80
+ #### Search Corpus
81
+ The search corpus is indexed using all method bodies parsed from the 24,549 GitHub repositories. In total, there are 4,716,814 methods in this corpus. The code search model will find relevant code snippets (i.e. method bodies) from this corpus given a natural language query. In this data release, we will provide the following information for each method in the corpus:
82
+
83
+ #### Evaluation Dataset
84
+ The evaluation dataset is composed of 287 Stack Overflow question and answer pairs
85
+
86
+ ### Data Fields
87
+
88
+ #### Search Corpus
89
+ - id: Each method in the corpus has a unique numeric identifier. This ID number will also be referenced in our evaluation dataset.
90
+ - filepath: The file path is in the format of :owner/:repo/relative-file-path-to-the-repo
91
+ method_name
92
+ - start_line: Starting line number of the method in the file.
93
+ - end_line: Ending line number of the method in the file.
94
+ - url: GitHub link to the method body with commit ID and line numbers encoded.
95
+
96
+ #### Evaluation Dataset
97
+ - stackoverflow_id: Stack Overflow post ID.
98
+ - question: Title fo the Stack Overflow post.
99
+ - question_url: URL of the Stack Overflow post.
100
+ - answer: Code snippet answer to the question.
101
+
102
+ ### Data Splits
103
+
104
+ [More Information Needed]
105
+
106
+ ## Dataset Creation
107
+
108
+ ### Curation Rationale
109
+
110
+ [More Information Needed]
111
+
112
+ ### Source Data
113
+
114
+ #### Initial Data Collection and Normalization
115
+
116
+ The most popular Android repositories on GitHub (ranked by the number of stars) is used to create the search corpus. For each repository that we indexed, we provide the link, specific to the commit that was used.5 In total, there are 24,549 repositories.
117
+
118
+ #### Who are the source language producers?
119
+
120
+ [More Information Needed]
121
+
122
+ ### Annotations
123
+
124
+ #### Annotation process
125
+
126
+ [More Information Needed]
127
+
128
+ #### Who are the annotators?
129
+
130
+ [More Information Needed]
131
+
132
+ ### Personal and Sensitive Information
133
+
134
+ [More Information Needed]
135
+
136
+ ## Considerations for Using the Data
137
+
138
+ ### Social Impact of Dataset
139
+
140
+ [More Information Needed]
141
+
142
+ ### Discussion of Biases
143
+
144
+ [More Information Needed]
145
+
146
+ ### Other Known Limitations
147
+
148
+ [More Information Needed]
149
+
150
+ ## Additional Information
151
+
152
+ ### Dataset Curators
153
+
154
+ Hongyu Li, Seohyun Kim and Satish Chandra
155
+
156
+ ### Licensing Information
157
+
158
+ CC-BY-NC 4.0 (Attr Non-Commercial Inter.)
159
+
160
+ ### Citation Information
161
+
162
+ arXiv:1908.09804 [cs.SE]
dataset_infos.json ADDED
@@ -0,0 +1 @@
 
1
+ {"evaluation_dataset": {"description": "Neural-Code-Search-Evaluation-Dataset presents an evaluation dataset consisting of natural language query and code snippet pairs and a search corpus consisting of code snippets collected from the most popular Android repositories on GitHub.\n", "citation": "@InProceedings{huggingface:dataset,\ntitle = {Neural Code Search Evaluation Dataset},\nauthors = {Hongyu Li, Seohyun Kim and Satish Chandra},\njournal = {arXiv e-prints},\nyear = 2018,\neid = {arXiv:1908.09804 [cs.SE]},\npages = {arXiv:1908.09804 [cs.SE]},\narchivePrefix = {arXiv},\neprint = {1908.09804},\n}\n", "homepage": "https://github.com/facebookresearch/Neural-Code-Search-Evaluation-Dataset/tree/master/data", "license": "CC-BY-NC 4.0 (Attr Non-Commercial Inter.)", "features": {"stackoverflow_id": {"dtype": "int32", "id": null, "_type": "Value"}, "question": {"dtype": "string", "id": null, "_type": "Value"}, "question_url": {"dtype": "string", "id": null, "_type": "Value"}, "question_author": {"dtype": "string", "id": null, "_type": "Value"}, "question_author_url": {"dtype": "string", "id": null, "_type": "Value"}, "answer": {"dtype": "string", "id": null, "_type": "Value"}, "answer_url": {"dtype": "string", "id": null, "_type": "Value"}, "answer_author": {"dtype": "string", "id": null, "_type": "Value"}, "answer_author_url": {"dtype": "string", "id": null, "_type": "Value"}, "examples": {"feature": {"dtype": "int32", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "examples_url": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "builder_name": "neural_code_search", "config_name": "evaluation_dataset", "version": {"version_str": "1.1.0", "description": null, "major": 1, "minor": 1, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 296848, "num_examples": 287, "dataset_name": "neural_code_search"}}, "download_checksums": {"https://raw.githubusercontent.com/facebookresearch/Neural-Code-Search-Evaluation-Dataset/master/data/287_android_questions.json": {"num_bytes": 383625, "checksum": "23117c7ee244ad7eddd863d1a92ea2d21d2c5f4e3d577d0d809bb3d88f797561"}}, "download_size": 383625, "post_processing_size": null, "dataset_size": 296848, "size_in_bytes": 680473}, "search_corpus": {"description": "Neural-Code-Search-Evaluation-Dataset presents an evaluation dataset consisting of natural language query and code snippet pairs and a search corpus consisting of code snippets collected from the most popular Android repositories on GitHub.\n", "citation": "@InProceedings{huggingface:dataset,\ntitle = {Neural Code Search Evaluation Dataset},\nauthors = {Hongyu Li, Seohyun Kim and Satish Chandra},\njournal = {arXiv e-prints},\nyear = 2018,\neid = {arXiv:1908.09804 [cs.SE]},\npages = {arXiv:1908.09804 [cs.SE]},\narchivePrefix = {arXiv},\neprint = {1908.09804},\n}\n", "homepage": "https://github.com/facebookresearch/Neural-Code-Search-Evaluation-Dataset/tree/master/data", "license": "CC-BY-NC 4.0 (Attr Non-Commercial Inter.)", "features": {"id": {"dtype": "int32", "id": null, "_type": "Value"}, "filepath": {"dtype": "string", "id": null, "_type": "Value"}, "method_name": {"dtype": "string", "id": null, "_type": "Value"}, "start_line": {"dtype": "int32", "id": null, "_type": "Value"}, "end_line": {"dtype": "int32", "id": null, "_type": "Value"}, "url": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "builder_name": "neural_code_search", "config_name": "search_corpus", "version": {"version_str": "1.1.0", "description": null, "major": 1, "minor": 1, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 1452630278, "num_examples": 4716814, "dataset_name": "neural_code_search"}}, "download_checksums": {"https://raw.githubusercontent.com/facebookresearch/Neural-Code-Search-Evaluation-Dataset/master/data/search_corpus_1.tar.gz": {"num_bytes": 50756713, "checksum": "ba6c96b949bd283d1935e58c99d9159896601c2eeff24c5787e61dd1da1ecd4f"}, "https://raw.githubusercontent.com/facebookresearch/Neural-Code-Search-Evaluation-Dataset/master/data/search_corpus_2.tar.gz": {"num_bytes": 70355830, "checksum": "a3cb354476a60ee45c29fe6629f5462d52965b082381340002882dd2192eddeb"}}, "download_size": 121112543, "post_processing_size": null, "dataset_size": 1452630278, "size_in_bytes": 1573742821}}
dummy/evaluation_dataset/1.1.0/dummy_data.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1b9412c674c7e88d22602408bca8d02e212111f0ce9589ec0c2449f46eb734a3
3
+ size 2764
dummy/search_corpus/1.1.0/dummy_data.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3fed6c3d4379a98e02c6403c65fb75278b29b0bd3696fc7f0d816335b0c0dbb6
3
+ size 1500
neural_code_search.py ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ """Neural-Code-Search-Evaluation-Dataset presents an evaluation dataset consisting of natural language query and code snippet pairs"""
16
+
17
+ from __future__ import absolute_import, division, print_function
18
+
19
+ import json
20
+ import os
21
+
22
+ import datasets
23
+
24
+
25
+ _CITATION = """\
26
+ @InProceedings{huggingface:dataset,
27
+ title = {Neural Code Search Evaluation Dataset},
28
+ authors = {Hongyu Li, Seohyun Kim and Satish Chandra},
29
+ journal = {arXiv e-prints},
30
+ year = 2018,
31
+ eid = {arXiv:1908.09804 [cs.SE]},
32
+ pages = {arXiv:1908.09804 [cs.SE]},
33
+ archivePrefix = {arXiv},
34
+ eprint = {1908.09804},
35
+ }
36
+ """
37
+
38
+ _DESCRIPTION = """\
39
+ Neural-Code-Search-Evaluation-Dataset presents an evaluation dataset \
40
+ consisting of natural language query and code snippet pairs and a search corpus \
41
+ consisting of code snippets collected from the most popular Android repositories \
42
+ on GitHub.
43
+ """
44
+
45
+ _HOMEPAGE = "https://github.com/facebookresearch/Neural-Code-Search-Evaluation-Dataset/tree/master/data"
46
+
47
+ _LICENSE = "CC-BY-NC 4.0 (Attr Non-Commercial Inter.)"
48
+
49
+ _BASE_URL = "https://raw.githubusercontent.com/facebookresearch/Neural-Code-Search-Evaluation-Dataset/master/data/"
50
+ _URLs = {
51
+ "evaluation_dataset": _BASE_URL + "287_android_questions.json",
52
+ "search_corpus_1": _BASE_URL + "search_corpus_1.tar.gz",
53
+ "search_corpus_2": _BASE_URL + "search_corpus_2.tar.gz",
54
+ }
55
+
56
+
57
+ class NeuralCodeSearch(datasets.GeneratorBasedBuilder):
58
+ """Neural Code Search Evaluation Dataset"""
59
+
60
+ VERSION = datasets.Version("1.1.0")
61
+
62
+ BUILDER_CONFIGS = [
63
+ datasets.BuilderConfig(
64
+ name="evaluation_dataset",
65
+ version=VERSION,
66
+ description="The evaluation dataset is composed of \
67
+ 287 Stack Overflow question and answer pairs",
68
+ ),
69
+ datasets.BuilderConfig(
70
+ name="search_corpus",
71
+ version=VERSION,
72
+ description="The search corpus is indexed using all \
73
+ method bodies parsed from the 24,549 GitHub repositories.",
74
+ ),
75
+ ]
76
+
77
+ FILENAME_MAP = {
78
+ "evaluation_dataset": "287_android_questions.json",
79
+ "search_corpus": "search_corpus_1.jsonl",
80
+ }
81
+
82
+ def _info(self):
83
+ if self.config.name == "evaluation_dataset":
84
+ features = datasets.Features(
85
+ {
86
+ "stackoverflow_id": datasets.Value("int32"),
87
+ "question": datasets.Value("string"),
88
+ "question_url": datasets.Value("string"),
89
+ "question_author": datasets.Value("string"),
90
+ "question_author_url": datasets.Value("string"),
91
+ "answer": datasets.Value("string"),
92
+ "answer_url": datasets.Value("string"),
93
+ "answer_author": datasets.Value("string"),
94
+ "answer_author_url": datasets.Value("string"),
95
+ "examples": datasets.features.Sequence(datasets.Value("int32")),
96
+ "examples_url": datasets.features.Sequence(datasets.Value("string")),
97
+ }
98
+ )
99
+ else:
100
+ features = datasets.Features(
101
+ {
102
+ "id": datasets.Value("int32"),
103
+ "filepath": datasets.Value("string"),
104
+ "method_name": datasets.Value("string"),
105
+ "start_line": datasets.Value("int32"),
106
+ "end_line": datasets.Value("int32"),
107
+ "url": datasets.Value("string"),
108
+ }
109
+ )
110
+
111
+ return datasets.DatasetInfo(
112
+ description=_DESCRIPTION,
113
+ features=features,
114
+ supervised_keys=None,
115
+ homepage=_HOMEPAGE,
116
+ license=_LICENSE,
117
+ citation=_CITATION,
118
+ )
119
+
120
+ def _split_generators(self, dl_manager):
121
+ """Returns SplitGenerators."""
122
+ my_urls = [url for config, url in _URLs.items() if config.startswith(self.config.name)]
123
+ data_dir = dl_manager.download_and_extract(my_urls)
124
+
125
+ return [
126
+ datasets.SplitGenerator(
127
+ name=datasets.Split.TRAIN,
128
+ gen_kwargs={
129
+ "datapath": data_dir,
130
+ "split": "train",
131
+ },
132
+ ),
133
+ ]
134
+
135
+ def _generate_examples(self, datapath, split):
136
+ """ Yields examples. """
137
+ id_ = 0
138
+ for dp in datapath:
139
+ if self.config.name == "evaluation_dataset":
140
+ with open(dp, encoding="utf-8") as f:
141
+ data = json.load(f)
142
+ for row in data:
143
+ yield id_, {
144
+ "stackoverflow_id": row["stackoverflow_id"],
145
+ "question": row["question"],
146
+ "question_url": row["question_url"],
147
+ "question_author": row["question_author"],
148
+ "question_author_url": row["question_author_url"],
149
+ "answer": row["answer"],
150
+ "answer_url": row["answer_url"],
151
+ "answer_author": row["answer_author"],
152
+ "answer_author_url": row["answer_author_url"],
153
+ "examples": row["examples"],
154
+ "examples_url": row["examples_url"],
155
+ }
156
+ id_ += 1
157
+ else:
158
+ for dirpath, _, fnames in sorted(os.walk(dp)):
159
+ for fname in sorted(fnames):
160
+ with open(os.path.join(dirpath, fname), encoding="utf-8") as f:
161
+ for row in f:
162
+ data_dict = json.loads(row)
163
+ yield id_, {
164
+ "id": data_dict["id"],
165
+ "filepath": data_dict["filepath"],
166
+ "method_name": data_dict["method_name"],
167
+ "start_line": data_dict["start_line"],
168
+ "end_line": data_dict["end_line"],
169
+ "url": data_dict["url"],
170
+ }
171
+ id_ += 1