jquave commited on
Commit
9fcb2ba
0 Parent(s):

Initial commit

Browse files
.gitattributes ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt 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
+ *.lz4 filter=lfs diff=lfs merge=lfs -text
12
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
13
+ *.model filter=lfs diff=lfs merge=lfs -text
14
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
15
+ *.npy filter=lfs diff=lfs merge=lfs -text
16
+ *.npz filter=lfs diff=lfs merge=lfs -text
17
+ *.onnx filter=lfs diff=lfs merge=lfs -text
18
+ *.ot filter=lfs diff=lfs merge=lfs -text
19
+ *.parquet filter=lfs diff=lfs merge=lfs -text
20
+ *.pb filter=lfs diff=lfs merge=lfs -text
21
+ *.pickle filter=lfs diff=lfs merge=lfs -text
22
+ *.pkl filter=lfs diff=lfs merge=lfs -text
23
+ *.pt filter=lfs diff=lfs merge=lfs -text
24
+ *.pth filter=lfs diff=lfs merge=lfs -text
25
+ *.rar filter=lfs diff=lfs merge=lfs -text
26
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
27
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
29
+ *.tar filter=lfs diff=lfs merge=lfs -text
30
+ *.tflite filter=lfs diff=lfs merge=lfs -text
31
+ *.tgz filter=lfs diff=lfs merge=lfs -text
32
+ *.wasm filter=lfs diff=lfs merge=lfs -text
33
+ *.xz filter=lfs diff=lfs merge=lfs -text
34
+ *.zip filter=lfs diff=lfs merge=lfs -text
35
+ *.zst filter=lfs diff=lfs merge=lfs -text
36
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
37
+ # Audio files - uncompressed
38
+ *.pcm filter=lfs diff=lfs merge=lfs -text
39
+ *.sam filter=lfs diff=lfs merge=lfs -text
40
+ *.raw filter=lfs diff=lfs merge=lfs -text
41
+ # Audio files - compressed
42
+ *.aac filter=lfs diff=lfs merge=lfs -text
43
+ *.flac filter=lfs diff=lfs merge=lfs -text
44
+ *.mp3 filter=lfs diff=lfs merge=lfs -text
45
+ *.ogg filter=lfs diff=lfs merge=lfs -text
46
+ *.wav filter=lfs diff=lfs merge=lfs -text
47
+ # Image files - uncompressed
48
+ *.bmp filter=lfs diff=lfs merge=lfs -text
49
+ *.gif filter=lfs diff=lfs merge=lfs -text
50
+ *.png filter=lfs diff=lfs merge=lfs -text
51
+ *.tiff filter=lfs diff=lfs merge=lfs -text
52
+ # Image files - compressed
53
+ *.jpg filter=lfs diff=lfs merge=lfs -text
54
+ *.jpeg filter=lfs diff=lfs merge=lfs -text
55
+ *.webp filter=lfs diff=lfs merge=lfs -text
.ipynb_checkpoints/prepare-checkpoint.ipynb ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": null,
6
+ "id": "1ba72ed3",
7
+ "metadata": {},
8
+ "outputs": [],
9
+ "source": [
10
+ "t_a = tarfile.open(f\"ethereum_0.tar\", \"r\")\n",
11
+ "# for itm in t_a:\n",
12
+ "# print(dir(itm))\n"
13
+ ]
14
+ },
15
+ {
16
+ "cell_type": "code",
17
+ "execution_count": 1,
18
+ "id": "b42aea41",
19
+ "metadata": {},
20
+ "outputs": [
21
+ {
22
+ "name": "stdout",
23
+ "output_type": "stream",
24
+ "text": [
25
+ "ls: cannot access '/home/jquave/dev/smart-contract-sanctuary/ethereum/contracts/mainnet/00': No such file or directory\r\n"
26
+ ]
27
+ }
28
+ ],
29
+ "source": [
30
+ "!ls ~/dev/smart-contract-sanctuary/ethereum/contracts/mainnet/00"
31
+ ]
32
+ },
33
+ {
34
+ "cell_type": "code",
35
+ "execution_count": null,
36
+ "id": "3969730c",
37
+ "metadata": {},
38
+ "outputs": [],
39
+ "source": [
40
+ "import os\n",
41
+ "import shutil\n",
42
+ "import json\n",
43
+ "import tarfile\n",
44
+ "\n",
45
+ "# archive = tarfile.open(\"ethereum.tar\", \"a\")\n",
46
+ "# archive.add(\"repo/a.git\", arcname=\"a.git\")\n",
47
+ "# archive.close()\n",
48
+ "\n",
49
+ "class A:\n",
50
+ " def __init__(self):\n",
51
+ " self.n = 0\n",
52
+ " self.i = 0\n",
53
+ " self.archive = tarfile.open(f\"ethereum_0.tar\", \"a\")\n",
54
+ " \n",
55
+ " def recursive_dump_sol_to_json(self, root_dir):\n",
56
+ " # Traverse the directory and list all .sol files\n",
57
+ " path_items = os.listdir(root_dir)\n",
58
+ " # print(path_items)\n",
59
+ " # Iterate over the list of .sol files\n",
60
+ " # archive = tarfile.open(f\"ethereum_{tar_split_n}.tar\", \"a\")\n",
61
+ " for path_item in path_items:\n",
62
+ " self.i = self.i + 1\n",
63
+ " if i % 10 == 0:\n",
64
+ " print(f\"{self.n}:{root_dir} path_item {path_item}\")\n",
65
+ " if path_item == \".\" or path_item == \"..\" or path_item ==\"../\" or path_item == \"./\":\n",
66
+ " return\n",
67
+ " # Read the contents of the .sol file\n",
68
+ " full_path_item = os.path.join(root_dir, path_item)\n",
69
+ " if os.path.isdir(full_path_item):\n",
70
+ " self.n = self.n + 1\n",
71
+ " self.recursive_dump_sol_to_json(full_path_item)\n",
72
+ " else:\n",
73
+ " if path_item.endswith(\".sol\"):\n",
74
+ "# f=1\n",
75
+ " if self.i > 20_000:\n",
76
+ " self.i = 0\n",
77
+ " self.n = self.n + 1\n",
78
+ " old_archive = self.archive\n",
79
+ " self.archive = tarfile.open(f\"ethereum_{self.n}.tar\", \"a\")\n",
80
+ " old_archive.close()\n",
81
+ " self.archive.add(full_path_item, arcname=f\"{path_item}.txt\")\n",
82
+ " \n",
83
+ "# Driver code\n",
84
+ "a = A()\n",
85
+ "root_dir = '../smart-contract-sanctuary/ethereum/contracts/mainnet'\n",
86
+ "a.recursive_dump_sol_to_json(root_dir)\n",
87
+ "# archive.close()"
88
+ ]
89
+ },
90
+ {
91
+ "cell_type": "code",
92
+ "execution_count": null,
93
+ "id": "c88f36bc",
94
+ "metadata": {},
95
+ "outputs": [],
96
+ "source": []
97
+ },
98
+ {
99
+ "cell_type": "code",
100
+ "execution_count": null,
101
+ "id": "88b22976",
102
+ "metadata": {},
103
+ "outputs": [],
104
+ "source": []
105
+ }
106
+ ],
107
+ "metadata": {
108
+ "kernelspec": {
109
+ "display_name": "Python 3 (ipykernel)",
110
+ "language": "python",
111
+ "name": "python3"
112
+ },
113
+ "language_info": {
114
+ "codemirror_mode": {
115
+ "name": "ipython",
116
+ "version": 3
117
+ },
118
+ "file_extension": ".py",
119
+ "mimetype": "text/x-python",
120
+ "name": "python",
121
+ "nbconvert_exporter": "python",
122
+ "pygments_lexer": "ipython3",
123
+ "version": "3.10.6"
124
+ }
125
+ },
126
+ "nbformat": 4,
127
+ "nbformat_minor": 5
128
+ }
README.md ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ annotations_creators:
3
+ - no-annotation
4
+ language_creators:
5
+ - found
6
+ language:
7
+ - en
8
+ multilinguality:
9
+ - monolingual
10
+ pretty_name: EDataset
11
+ size_categories:
12
+ - 1M<n<10M
13
+ source_datasets:
14
+ - original
15
+ task_categories:
16
+ - text-generation
17
+ - fill-mask
18
+ task_ids:
19
+ - language-modeling
20
+ - masked-language-modeling
21
+ dataset_info:
22
+ features:
23
+ - name: text
24
+ dtype: string
25
+ config_name: plain_text
26
+ ---
27
+
28
+ ## E micro Dataset
29
+
30
+ This is the card for e micro dataset
e_micro.py ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ """E micro Corpus"""
16
+
17
+ import re
18
+
19
+ import datasets
20
+
21
+
22
+ _CITATION = """\
23
+ @misc{E Dataset,
24
+ title={E Dataset},
25
+ author={Jameson Quave},
26
+ howpublished{\\url{https://huggingface.co/jquave}},
27
+ year={2023}
28
+ }
29
+ """
30
+
31
+ _DESCRIPTION = """\
32
+ An open-source replication of E micro
33
+ """
34
+
35
+ _DATA_FILES = ["ethereum_00.tar"]
36
+
37
+ print(_DATA_FILES)
38
+
39
+
40
+ class EDataset(datasets.GeneratorBasedBuilder):
41
+ """The E dataset."""
42
+
43
+ BUILDER_CONFIGS = [
44
+ datasets.BuilderConfig(
45
+ name="plain_text",
46
+ description="Plain text",
47
+ version=datasets.Version("1.0.0"),
48
+ )
49
+ ]
50
+
51
+ def _info(self):
52
+ return datasets.DatasetInfo(
53
+ description=_DESCRIPTION,
54
+ features=datasets.Features({"train": datasets.Value("string")}),
55
+ homepage="https://huggingface.co/jquave",
56
+ citation=_CITATION,
57
+ )
58
+
59
+ def _split_generators(self, dl_manager):
60
+ archives = dl_manager.download(_DATA_FILES)
61
+ return [
62
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={
63
+ "archive_iterators": [
64
+ dl_manager.iter_archive(archive) for archive in archives
65
+ ],
66
+ "iter_archive": dl_manager.iter_archive
67
+ }),
68
+ ]
69
+
70
+ def _generate_examples(self, archive_iterators, iter_archive):
71
+ """Yields examples."""
72
+ for archive_iterator in archive_iterators:
73
+ for code_path, code_f in archive_iterator:
74
+ if code_path.endswith(".sol.txt") or code_path.endswith(".sol"):
75
+ yield code_path, {"train": re.sub("\n\n\n+", "\n\n", code_f.read().decode("utf-8")).strip()}
ethereum_00.tar ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c5d997676704dec6574cd17f16451559ede55e0390f67c7af259c46bd9784282
3
+ size 159425
prepare.ipynb ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": null,
6
+ "id": "1ba72ed3",
7
+ "metadata": {},
8
+ "outputs": [],
9
+ "source": [
10
+ "t_a = tarfile.open(f\"ethereum_0.tar\", \"r\")\n",
11
+ "# for itm in t_a:\n",
12
+ "# print(dir(itm))\n"
13
+ ]
14
+ },
15
+ {
16
+ "cell_type": "code",
17
+ "execution_count": 1,
18
+ "id": "b42aea41",
19
+ "metadata": {},
20
+ "outputs": [
21
+ {
22
+ "name": "stdout",
23
+ "output_type": "stream",
24
+ "text": [
25
+ "ls: cannot access '/home/jquave/dev/smart-contract-sanctuary/ethereum/contracts/mainnet/00': No such file or directory\r\n"
26
+ ]
27
+ }
28
+ ],
29
+ "source": [
30
+ "!ls ~/dev/smart-contract-sanctuary/ethereum/contracts/mainnet/00"
31
+ ]
32
+ },
33
+ {
34
+ "cell_type": "code",
35
+ "execution_count": null,
36
+ "id": "3969730c",
37
+ "metadata": {},
38
+ "outputs": [],
39
+ "source": [
40
+ "import os\n",
41
+ "import shutil\n",
42
+ "import json\n",
43
+ "import tarfile\n",
44
+ "\n",
45
+ "# archive = tarfile.open(\"ethereum.tar\", \"a\")\n",
46
+ "# archive.add(\"repo/a.git\", arcname=\"a.git\")\n",
47
+ "# archive.close()\n",
48
+ "\n",
49
+ "class A:\n",
50
+ " def __init__(self):\n",
51
+ " self.n = 0\n",
52
+ " self.i = 0\n",
53
+ " self.archive = tarfile.open(f\"ethereum_0.tar\", \"a\")\n",
54
+ " \n",
55
+ " def recursive_dump_sol_to_json(self, root_dir):\n",
56
+ " # Traverse the directory and list all .sol files\n",
57
+ " path_items = os.listdir(root_dir)\n",
58
+ " # print(path_items)\n",
59
+ " # Iterate over the list of .sol files\n",
60
+ " # archive = tarfile.open(f\"ethereum_{tar_split_n}.tar\", \"a\")\n",
61
+ " for path_item in path_items:\n",
62
+ " self.i = self.i + 1\n",
63
+ " if i % 10 == 0:\n",
64
+ " print(f\"{self.n}:{root_dir} path_item {path_item}\")\n",
65
+ " if path_item == \".\" or path_item == \"..\" or path_item ==\"../\" or path_item == \"./\":\n",
66
+ " return\n",
67
+ " # Read the contents of the .sol file\n",
68
+ " full_path_item = os.path.join(root_dir, path_item)\n",
69
+ " if os.path.isdir(full_path_item):\n",
70
+ " self.n = self.n + 1\n",
71
+ " self.recursive_dump_sol_to_json(full_path_item)\n",
72
+ " else:\n",
73
+ " if path_item.endswith(\".sol\"):\n",
74
+ "# f=1\n",
75
+ " if self.i > 20_000:\n",
76
+ " self.i = 0\n",
77
+ " self.n = self.n + 1\n",
78
+ " old_archive = self.archive\n",
79
+ " self.archive = tarfile.open(f\"ethereum_{self.n}.tar\", \"a\")\n",
80
+ " old_archive.close()\n",
81
+ " self.archive.add(full_path_item, arcname=f\"{path_item}.txt\")\n",
82
+ " \n",
83
+ "# Driver code\n",
84
+ "a = A()\n",
85
+ "root_dir = '../smart-contract-sanctuary/ethereum/contracts/mainnet'\n",
86
+ "a.recursive_dump_sol_to_json(root_dir)\n",
87
+ "# archive.close()"
88
+ ]
89
+ },
90
+ {
91
+ "cell_type": "code",
92
+ "execution_count": null,
93
+ "id": "c88f36bc",
94
+ "metadata": {},
95
+ "outputs": [],
96
+ "source": []
97
+ },
98
+ {
99
+ "cell_type": "code",
100
+ "execution_count": null,
101
+ "id": "88b22976",
102
+ "metadata": {},
103
+ "outputs": [],
104
+ "source": []
105
+ }
106
+ ],
107
+ "metadata": {
108
+ "kernelspec": {
109
+ "display_name": "Python 3 (ipykernel)",
110
+ "language": "python",
111
+ "name": "python3"
112
+ },
113
+ "language_info": {
114
+ "codemirror_mode": {
115
+ "name": "ipython",
116
+ "version": 3
117
+ },
118
+ "file_extension": ".py",
119
+ "mimetype": "text/x-python",
120
+ "name": "python",
121
+ "nbconvert_exporter": "python",
122
+ "pygments_lexer": "ipython3",
123
+ "version": "3.10.6"
124
+ }
125
+ },
126
+ "nbformat": 4,
127
+ "nbformat_minor": 5
128
+ }
test_e.py ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ import logging
2
+ from datasets import load_dataset
3
+
4
+ logging.basicConfig(level=logging.INFO)
5
+
6
+ dataset = load_dataset("./e_micro.py")
7
+ print(dataset["train"][0])
8
+