Ayush-Singh commited on
Commit
13a5bef
·
1 Parent(s): 5771c00

Some update

Browse files
data_prep.ipynb DELETED
@@ -1,165 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "code",
5
- "execution_count": null,
6
- "id": "dc45342a",
7
- "metadata": {},
8
- "outputs": [
9
- {
10
- "ename": "",
11
- "evalue": "",
12
- "output_type": "error",
13
- "traceback": [
14
- "\u001b[1;31mJupyter cannot be started. Error attempting to locate Jupyter: Running cells with 'Python 3.12.2' requires the notebook package.\n",
15
- "\u001b[1;31mInstall 'jupyter and notebook' into the Python environment. \n",
16
- "\u001b[1;31mCommand: 'python -m pip install jupyter notebook -U\n",
17
- "\u001b[1;31mor\n",
18
- "\u001b[1;31mconda install jupyter notebook -U'\n",
19
- "\u001b[1;31mClick <a href='https://aka.ms/installJupyterForVSCode'>here</a> for more info."
20
- ]
21
- }
22
- ],
23
- "source": [
24
- "import orjson\n",
25
- "from tqdm import tqdm\n",
26
- "\n",
27
- "INPUT = \"datasets/gh_25_github_io_repos_collapsed.jsonl\"\n",
28
- "OUTPUT = \"datasets/gh_25_github_io_repos_filtered.jsonl\"\n",
29
- "\n",
30
- "USEFUL_EXTS = {\n",
31
- " \".html\", \".css\", \".js\", \".ts\", \".tsx\", \".jsx\",\n",
32
- " \".vue\", \".astro\", \".scss\", \".sass\", \".less\", \".py\"\n",
33
- "}\n",
34
- "\n",
35
- "NON_USEFUL_EXTS = {\n",
36
- " \".md\", \".rst\", \".txt\"\n",
37
- "}\n",
38
- "\n",
39
- "CONFIG_EXTS = {\n",
40
- " \".yml\", \".yaml\", \".json\", \".toml\"\n",
41
- "}\n",
42
- "\n",
43
- "MIN_TOTAL_FILES = 10\n",
44
- "MIN_TOTAL_SIZE = 100_000\n",
45
- "MIN_USEFUL_FRACTION = 0.7\n",
46
- "MAX_NON_USEFUL_FRACTION = 0.2\n",
47
- "\n",
48
- "\n",
49
- "def is_good_web_repo(obj):\n",
50
- " paths = obj[\"file_path\"]\n",
51
- " sizes = obj[\"size\"]\n",
52
- "\n",
53
- " total_files = len(paths)\n",
54
- " total_size = sum(sizes)\n",
55
- "\n",
56
- " if total_files < MIN_TOTAL_FILES:\n",
57
- " return False\n",
58
- " if total_size < MIN_TOTAL_SIZE:\n",
59
- " return False\n",
60
- "\n",
61
- " useful = non_useful = config = 0\n",
62
- "\n",
63
- " for p in paths:\n",
64
- " p = p.lower()\n",
65
- " if any(p.endswith(ext) for ext in USEFUL_EXTS):\n",
66
- " useful += 1\n",
67
- " elif any(p.endswith(ext) for ext in NON_USEFUL_EXTS):\n",
68
- " non_useful += 1\n",
69
- " elif any(p.endswith(ext) for ext in CONFIG_EXTS):\n",
70
- " config += 1\n",
71
- "\n",
72
- " useful_frac = useful / total_files\n",
73
- " non_useful_frac = non_useful / total_files\n",
74
- "\n",
75
- " if non_useful_frac > MAX_NON_USEFUL_FRACTION:\n",
76
- " return False\n",
77
- "\n",
78
- " return useful_frac >= MIN_USEFUL_FRACTION\n",
79
- "\n",
80
- "\n",
81
- "kept = 0\n",
82
- "with open(INPUT, \"rb\") as fin, open(OUTPUT, \"wb\") as fout:\n",
83
- " for line in tqdm(fin, desc=\"Filtering repos\"):\n",
84
- " obj = orjson.loads(line)\n",
85
- " if is_good_web_repo(obj):\n",
86
- " fout.write(orjson.dumps(obj) + b\"\\n\")\n",
87
- " kept += 1\n",
88
- "\n",
89
- "print(f\"✅ Kept {kept} high-quality web repos\")"
90
- ]
91
- },
92
- {
93
- "cell_type": "code",
94
- "execution_count": null,
95
- "id": "4da42790",
96
- "metadata": {},
97
- "outputs": [],
98
- "source": [
99
- "from datasets import load_dataset\n",
100
- "\n",
101
- "# Load your dataset (replace with the actual dataset path or name)\n",
102
- "ds = load_dataset(\"Ayush-Singh/stack-githubio-live\", split=\"train\")\n",
103
- "\n",
104
- "USEFUL_WEB_LANGS = {\n",
105
- " \"HTML\", \"CSS\", \"JavaScript\", \"TypeScript\", \"TSX\", \"JSX\",\n",
106
- " \"Vue\", \"Astro\", \"SCSS\", \"Sass\", \"Less\", \"Python\"\n",
107
- "}\n",
108
- "\n",
109
- "NON_USEFUL_DOMINANT_LANGS = {\n",
110
- " \"Markdown\", \"RMarkdown\", \"R\", \"Jupyter Notebook\"\n",
111
- "}\n",
112
- "\n",
113
- "MIN_USEFUL_FRACTION = 0.7\n",
114
- "MIN_TOTAL_FILES = 5\n",
115
- "MIN_TOTAL_LINES = 2000\n",
116
- "\n",
117
- "def is_prod_web_repo(repo):\n",
118
- " lang_frac = repo.get(\"repo_language_fraction_dict\", {})\n",
119
- " \n",
120
- " useful_fraction = sum(\n",
121
- " frac for lang, frac in lang_frac.items() if lang in USEFUL_WEB_LANGS and frac\n",
122
- " )\n",
123
- " \n",
124
- " non_useful_fraction = sum(\n",
125
- " frac for lang, frac in lang_frac.items() if lang in NON_USEFUL_DOMINANT_LANGS and frac\n",
126
- " )\n",
127
- " \n",
128
- " if non_useful_fraction > 0.2:\n",
129
- " return False\n",
130
- " if repo.get(\"repo_total_files\", 0) < MIN_TOTAL_FILES:\n",
131
- " return False\n",
132
- " if repo.get(\"repo_total_num_lines\", 0) < MIN_TOTAL_LINES:\n",
133
- " return False\n",
134
- " \n",
135
- " return useful_fraction >= MIN_USEFUL_FRACTION\n",
136
- "\n",
137
- "# Filter HF dataset\n",
138
- "prod_web_repos = ds.filter(is_prod_web_repo)\n",
139
- "\n",
140
- "print(f\"Found {len(prod_web_repos)} production-level web repos\")"
141
- ]
142
- }
143
- ],
144
- "metadata": {
145
- "kernelspec": {
146
- "display_name": "DeepLearning",
147
- "language": "python",
148
- "name": "python3"
149
- },
150
- "language_info": {
151
- "codemirror_mode": {
152
- "name": "ipython",
153
- "version": 3
154
- },
155
- "file_extension": ".py",
156
- "mimetype": "text/x-python",
157
- "name": "python",
158
- "nbconvert_exporter": "python",
159
- "pygments_lexer": "ipython3",
160
- "version": "3.10.16"
161
- }
162
- },
163
- "nbformat": 4,
164
- "nbformat_minor": 5
165
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
gh_25_stack_heuristic_hexo_static_jekyll_dataset/stack_githubio_cwv_heuristic_results.jsonl CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:7182cd6f082ff51e8b88b5a8faae6cfcbfb32fc8df00925b20300180bc6d463b
3
  size 32324582
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f17aab05d9d0e68cc683a00b784b8cc52b342c4d1802a065fb691efbe6fc15b0
3
  size 32324582
successful_visual_verified_repos.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e41e128918becfb25ba95a835cba5e207e3606e11b70b967d85a622e92fd3cef
3
+ size 384340