andstor commited on
Commit
5190e5d
1 Parent(s): f6893c5

Add initial data

Browse files
README.md ADDED
@@ -0,0 +1,189 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ annotations_creators:
3
+ - no-annotation
4
+ language_creators:
5
+ - machine-generated
6
+ language:
7
+ - code
8
+ license:
9
+ - other
10
+ multilinguality:
11
+ - multilingual
12
+ size_categories:
13
+ - 100K<n<1M
14
+ - 10K<n<100K
15
+ - 1M<n<10M
16
+ source_datasets:
17
+ - original
18
+ dataset_info:
19
+ - config_name: all
20
+ features:
21
+ - name: repository_name
22
+ dtype: string
23
+ - name: file_path
24
+ dtype: string
25
+ - name: language
26
+ dtype: string
27
+ - name: url
28
+ dtype: string
29
+ - name: contents
30
+ dtype: string
31
+ splits:
32
+ - name: train
33
+ num_bytes: 4597566968
34
+ num_examples: 481456
35
+ - name: test
36
+ num_bytes: 244185049
37
+ num_examples: 27032
38
+ - name: validation
39
+ num_bytes: 208172780
40
+ num_examples: 23262
41
+ download_size: 5328510079
42
+ dataset_size: 5049924797
43
+ - config_name: java
44
+ features:
45
+ - name: repository_name
46
+ dtype: string
47
+ - name: file_path
48
+ dtype: string
49
+ - name: language
50
+ dtype: string
51
+ - name: url
52
+ dtype: string
53
+ - name: contents
54
+ dtype: string
55
+ splits:
56
+ - name: train
57
+ num_bytes: 1508021640
58
+ num_examples: 124201
59
+ - name: test
60
+ num_bytes: 83498294
61
+ num_examples: 7672
62
+ - name: validation
63
+ num_bytes: 49495187
64
+ num_examples: 4622
65
+ download_size: 1719645289
66
+ dataset_size: 1641015121
67
+ - config_name: go
68
+ features:
69
+ - name: repository_name
70
+ dtype: string
71
+ - name: file_path
72
+ dtype: string
73
+ - name: language
74
+ dtype: string
75
+ - name: url
76
+ dtype: string
77
+ - name: contents
78
+ dtype: string
79
+ splits:
80
+ - name: train
81
+ num_bytes: 445935389
82
+ num_examples: 52467
83
+ - name: test
84
+ num_bytes: 22662672
85
+ num_examples: 2661
86
+ - name: validation
87
+ num_bytes: 14949171
88
+ num_examples: 1991
89
+ download_size: 525469198
90
+ dataset_size: 483547232
91
+ - config_name: python
92
+ features:
93
+ - name: repository_name
94
+ dtype: string
95
+ - name: file_path
96
+ dtype: string
97
+ - name: language
98
+ dtype: string
99
+ - name: url
100
+ dtype: string
101
+ - name: contents
102
+ dtype: string
103
+ splits:
104
+ - name: train
105
+ num_bytes: 966000949
106
+ num_examples: 83739
107
+ - name: test
108
+ num_bytes: 53223810
109
+ num_examples: 4989
110
+ - name: validation
111
+ num_bytes: 51072608
112
+ num_examples: 4589
113
+ download_size: 1117084868
114
+ dataset_size: 1070297367
115
+ - config_name: javascript
116
+ features:
117
+ - name: repository_name
118
+ dtype: string
119
+ - name: file_path
120
+ dtype: string
121
+ - name: language
122
+ dtype: string
123
+ - name: url
124
+ dtype: string
125
+ - name: contents
126
+ dtype: string
127
+ splits:
128
+ - name: train
129
+ num_bytes: 533231855
130
+ num_examples: 40913
131
+ - name: test
132
+ num_bytes: 28571674
133
+ num_examples: 2176
134
+ - name: validation
135
+ num_bytes: 36688764
136
+ num_examples: 2586
137
+ download_size: 633172343
138
+ dataset_size: 598492293
139
+ - config_name: ruby
140
+ features:
141
+ - name: repository_name
142
+ dtype: string
143
+ - name: file_path
144
+ dtype: string
145
+ - name: language
146
+ dtype: string
147
+ - name: url
148
+ dtype: string
149
+ - name: contents
150
+ dtype: string
151
+ splits:
152
+ - name: train
153
+ num_bytes: 132300659
154
+ num_examples: 16932
155
+ - name: test
156
+ num_bytes: 5125555
157
+ num_examples: 822
158
+ - name: validation
159
+ num_bytes: 4189342
160
+ num_examples: 803
161
+ download_size: 147603200
162
+ dataset_size: 141615556
163
+ - config_name: php
164
+ features:
165
+ - name: repository_name
166
+ dtype: string
167
+ - name: file_path
168
+ dtype: string
169
+ - name: language
170
+ dtype: string
171
+ - name: url
172
+ dtype: string
173
+ - name: contents
174
+ dtype: string
175
+ splits:
176
+ - name: train
177
+ num_bytes: 1012076476
178
+ num_examples: 163204
179
+ - name: test
180
+ num_bytes: 51103044
181
+ num_examples: 8712
182
+ - name: validation
183
+ num_bytes: 51777708
184
+ num_examples: 8671
185
+ download_size: 1185535181
186
+ dataset_size: 1114957228
187
+ ---
188
+
189
+ # Dataset Card for CodeSearchNet Files
code_search_net_files.py ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
16
+ # Lint as: python3
17
+ """CodeSearchNet corpus Files: proxy dataset for semantic code search"""
18
+
19
+ # TODO: add licensing info in the examples
20
+ # TODO: log richer informations (especially while extracting the jsonl.gz files)
21
+ # TODO: enable custom configs; such as: "java+python"
22
+ # TODO: enable fetching examples with a given license, eg: "java_MIT"
23
+
24
+
25
+ import json
26
+ import os
27
+
28
+ import datasets
29
+
30
+
31
+ _CITATION = """\
32
+ @article{husain2019codesearchnet,
33
+ title={{CodeSearchNet} challenge: Evaluating the state of semantic code search},
34
+ author={Husain, Hamel and Wu, Ho-Hsiang and Gazit, Tiferet and Allamanis, Miltiadis and Brockschmidt, Marc},
35
+ journal={arXiv preprint arXiv:1909.09436},
36
+ year={2019}
37
+ }
38
+ """
39
+
40
+ _DESCRIPTION = """\
41
+ CodeSearchNet corpus contains about 6 million functions from open-source code \
42
+ spanning six programming languages (Go, Java, JavaScript, PHP, Python, and Ruby). \
43
+ The CodeSearchNet Corpus also contains automatically generated query-like \
44
+ natural language for 2 million functions, obtained from mechanically scraping \
45
+ and preprocessing associated function documentation.
46
+ """
47
+
48
+ _HOMEPAGE = "https://github.com/github/CodeSearchNet"
49
+
50
+ _LICENSE = "Various"
51
+
52
+ _DATA_DIR_URL = "data"
53
+ _AVAILABLE_LANGUAGES = ["python", "java", "javascript", "go", "ruby", "php"]
54
+ _URLs = {language: f"{language}.jsonl" for language in _AVAILABLE_LANGUAGES}
55
+ # URLs for "all" are just the concatenation of URLs for all languages
56
+ _URLs["all"] = _URLs.copy()
57
+
58
+
59
+ class CodeSearchNet(datasets.GeneratorBasedBuilder):
60
+ """ "Extended CodeSearchNet corpus: proxy dataset for semantic code search."""
61
+
62
+ VERSION = datasets.Version("1.0.0", "Add Extended CodeSearchNet corpus dataset")
63
+ BUILDER_CONFIGS = [
64
+ datasets.BuilderConfig(
65
+ name="all",
66
+ version=VERSION,
67
+ description="All available languages: Java, Go, Javascript, Python, PHP, Ruby",
68
+ ),
69
+ datasets.BuilderConfig(
70
+ name="java",
71
+ version=VERSION,
72
+ description="Java language",
73
+ ),
74
+ datasets.BuilderConfig(
75
+ name="go",
76
+ version=VERSION,
77
+ description="Go language",
78
+ ),
79
+ datasets.BuilderConfig(
80
+ name="python",
81
+ version=VERSION,
82
+ description="Pyhton language",
83
+ ),
84
+ datasets.BuilderConfig(
85
+ name="javascript",
86
+ version=VERSION,
87
+ description="Javascript language",
88
+ ),
89
+ datasets.BuilderConfig(
90
+ name="ruby",
91
+ version=VERSION,
92
+ description="Ruby language",
93
+ ),
94
+ datasets.BuilderConfig(
95
+ name="php",
96
+ version=VERSION,
97
+ description="PHP language",
98
+ ),
99
+ ]
100
+
101
+ DEFAULT_CONFIG_NAME = "all"
102
+
103
+ def _info(self):
104
+ return datasets.DatasetInfo(
105
+ description=_DESCRIPTION,
106
+ features=datasets.Features(
107
+ {
108
+ "repository_name": datasets.Value("string"),
109
+ "file_path": datasets.Value("string"),
110
+ "language": datasets.Value("string"),
111
+ "url": datasets.Value("string"),
112
+ "contents": datasets.Value("string")
113
+ # TODO - add licensing info in the examples
114
+ }
115
+ ),
116
+ # No default supervised keys
117
+ supervised_keys=None,
118
+ homepage=_HOMEPAGE,
119
+ license=_LICENSE,
120
+ citation=_CITATION,
121
+ )
122
+
123
+ def _split_generators(self, dl_manager):
124
+ """Returns SplitGenerators.
125
+
126
+ Note: The original data is stored in S3, and follows this unusual directory structure:
127
+ ```
128
+ .
129
+ ├── <language_name> # e.g. python
130
+ │ └── final
131
+ │ └── jsonl
132
+ │ ├── test
133
+ │ │ └── <language_name>_test_0.jsonl.gz
134
+ │ ├── train
135
+ │ │ ├── <language_name>_train_0.jsonl.gz
136
+ │ │ ├── <language_name>_train_1.jsonl.gz
137
+ │ │ ├── ...
138
+ │ │ └── <language_name>_train_n.jsonl.gz
139
+ │ └── valid
140
+ �� └── <language_name>_valid_0.jsonl.gz
141
+ ├── <language_name>_dedupe_definitions_v2.pkl
142
+ └── <language_name>_licenses.pkl
143
+ ```
144
+ """
145
+ data_urls = _URLs[self.config.name]
146
+ if isinstance(data_urls, str):
147
+ data_urls = {self.config.name: data_urls}
148
+ split2dirs = {
149
+ split_name: [os.path.join(_DATA_DIR_URL, split_name, path) for path in data_urls.values()]
150
+ for split_name in ["train", "test", "valid"]
151
+ }
152
+ downloaded_files = dl_manager.download_and_extract(split2dirs)
153
+ return [
154
+ datasets.SplitGenerator(
155
+ name=datasets.Split.TRAIN,
156
+ gen_kwargs={
157
+ "filepaths": downloaded_files["train"],
158
+ },
159
+ ),
160
+
161
+ datasets.SplitGenerator(
162
+ name=datasets.Split.TEST,
163
+ gen_kwargs={
164
+ "filepaths": downloaded_files["test"],
165
+ },
166
+ ),
167
+ datasets.SplitGenerator(
168
+ name=datasets.Split.VALIDATION,
169
+ gen_kwargs={
170
+ "filepaths": downloaded_files["valid"],
171
+ },
172
+ ),
173
+ ]
174
+
175
+ def _generate_examples(self, filepaths):
176
+ """Yields the examples by iterating through the available jsonl files."""
177
+ for file_id_, filepath in enumerate(filepaths):
178
+ with open(filepath, encoding="utf-8") as f:
179
+ for row_id_, row in enumerate(f):
180
+ # Key of the example = file_id + row_id,
181
+ # to ensure all examples have a distinct key
182
+ id_ = f"{file_id_}_{row_id_}"
183
+ data = json.loads(row)
184
+ yield id_, {
185
+ "repository_name": data["repository_name"],
186
+ "file_path": data["file_path"],
187
+ "language": data["language"],
188
+ "url": data["url"],
189
+ "contents": data["contents"],
190
+ }
data/licenses/go_licenses.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:130c7393db868a4dda13d98e634d01f9a47dffee5337d0138140b7766752e8e6
3
+ size 110543810
data/licenses/java_licenses.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:01bdc6d498629a7a7ac143878e51b73e0db12512e1bebbe876af280dc2d42fed
3
+ size 87186641
data/licenses/javascript_licenses.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7ae57111b6d275f0d0b9a832d7c89003b5245f6fe9627658eb469f276d6181f1
3
+ size 196114558
data/licenses/php_licenses.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e35c7db533af777faafaf81707897a0420dde2943529d845e43f1f0a3fee8207
3
+ size 132365537
data/licenses/python_licenses.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:404333e78827bd1743073251c65333239e625820d917bbcaf821dd0fd4433897
3
+ size 134172919
data/licenses/ruby_licenses.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:81a66606f55c37ed35e8b60be1d9e35ca14ae92e5e9522f3fb2dc2068fb06224
3
+ size 45964554
data/test/go.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b6b398eafc936f5d9021dccb4e34a09b485649d210b4ee3bd11c99c6ad9ddf46
3
+ size 24828295
data/test/java.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b922775dd44c8179a37d4295a3b324d3c981a7d93f69ff36ae65cfbd7e1d9d63
3
+ size 87789100
data/test/javascript.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c4bde6312d8c4d946193e7a2021b3f09439fd5b20aa5c0ee459cbf3de7412c53
3
+ size 30165723
data/test/php.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a600394cf116260a0a35b099b6816172d8e669bf69b2d868e5f1d117508ee47e
3
+ size 54707323
data/test/python.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:31529a238efd1df1fd1071cf156a62361bbdebf37fb8e72505b9bb8c8331c678
3
+ size 55541175
data/test/ruby.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:36c8a6dd054f8c6c569c5d27f433685b4a0402a8374127eb78ed0216c591bae5
3
+ size 5381681
data/train/go.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5fc6c405ba23ab426679f6039154822e42461242f5e04ba791526c17c3610b76
3
+ size 484478829
data/train/java.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:713e9de96964a4f96005763bf9a071fe58a2355db7bf8fdf5045a59445f5a5e1
3
+ size 1580026681
data/train/javascript.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0a5611c25619aa4ff3b238bc5ea1bf0c2d543db6f7c13b4bbab1d6088c63f593
3
+ size 564219663
data/train/php.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1b0daec2dc730303c47425748f58aad4a39327dc374ec1324b8b3ed877e42156
3
+ size 1075735490
data/train/python.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0b1a0fac1cba192e8a5e6ff62ca7f5beaa6ac047459783d4d9d013c6321642f5
3
+ size 1008181723
data/train/ruby.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:06a6188fbb8f63561f93855e91fb82a496f3f5008ef234251a255185f2f60323
3
+ size 137833138
data/valid/go.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:44c2eafeb4bf3f05c29e4d25c611df0bcd705eb2deae21d4a7902dd689f74405
3
+ size 16162074
data/valid/java.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6169f90fdd407ca0d681aeaa8831bc053ee0327cf66a86eb8a22bb9151d03d37
3
+ size 51829508
data/valid/javascript.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:aeece90f9c5b94f1e2d02848003d848888e555c397d4dbc9ccdcc28b5a2ffd17
3
+ size 38786957
data/valid/php.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b789a5190cc5d0ece37f03be83a8a4ff2690226fb96aa8ff6abf7d5c7bd2a077
3
+ size 55092368
data/valid/python.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1a34729de7436b4584ac5c99e7f8930cc84f8cc2d93a0ce5cb5bed1045b80771
3
+ size 53361970
data/valid/ruby.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1291bbe23d3b46a8b26ecd572b197a57c9f2425777ee78222397b9460c51581a
3
+ size 4388381
data/valid/validation_files.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9d567351df1a8b314db9bd2e9a712d586e233d2df0c5b40dfea7dbfb88e21182
3
+ size 219621258