ronantakizawa commited on
Commit
e2282be
·
verified ·
1 Parent(s): 0d985aa

Upload github-top-projects.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. github-top-projects.py +135 -0
github-top-projects.py ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Dataset loading script for github-top-projects with multiple configurations
3
+ """
4
+ import csv
5
+ import datasets
6
+
7
+ _CITATION = """\
8
+ @dataset{github_trending_2013_2025,
9
+ title={GitHub Trending Projects Dataset (2013-2025)},
10
+ author={Ronan Takizawa},
11
+ year={2025},
12
+ publisher={Hugging Face},
13
+ url={https://huggingface.co/datasets/ronantakizawa/github-top-projects}
14
+ }
15
+ """
16
+
17
+ _DESCRIPTION = """\
18
+ A comprehensive dataset of 423,098 GitHub trending repository entries spanning 12+ years (August 2013 - November 2025).
19
+
20
+ This dataset has two configurations:
21
+ - 'full': Complete daily trending data (423,098 entries)
22
+ - 'monthly': Top 25 repositories per month with weighted scoring (3,200 entries)
23
+ """
24
+
25
+ _HOMEPAGE = "https://huggingface.co/datasets/ronantakizawa/github-top-projects"
26
+
27
+ _LICENSE = "MIT"
28
+
29
+ _URLS = {
30
+ "full": "github-trending-projects-full.csv",
31
+ "monthly": "github-top-projects-by-month.csv",
32
+ }
33
+
34
+
35
+ class GitHubTopProjectsConfig(datasets.BuilderConfig):
36
+ """BuilderConfig for GitHubTopProjects."""
37
+
38
+ def __init__(self, **kwargs):
39
+ """BuilderConfig for GitHubTopProjects.
40
+ Args:
41
+ **kwargs: keyword arguments forwarded to super.
42
+ """
43
+ super(GitHubTopProjectsConfig, self).__init__(**kwargs)
44
+
45
+
46
+ class GitHubTopProjects(datasets.GeneratorBasedBuilder):
47
+ """GitHub Trending Projects Dataset"""
48
+
49
+ BUILDER_CONFIGS = [
50
+ GitHubTopProjectsConfig(
51
+ name="full",
52
+ version=datasets.Version("1.0.0"),
53
+ description="Complete daily trending data (423,098 entries)",
54
+ ),
55
+ GitHubTopProjectsConfig(
56
+ name="monthly",
57
+ version=datasets.Version("1.0.0"),
58
+ description="Top 25 repositories per month with weighted scoring (3,200 entries)",
59
+ ),
60
+ ]
61
+
62
+ DEFAULT_CONFIG_NAME = "full"
63
+
64
+ def _info(self):
65
+ if self.config.name == "full":
66
+ features = datasets.Features(
67
+ {
68
+ "name": datasets.Value("string"),
69
+ "star_count": datasets.Value("int64"),
70
+ "fork_count": datasets.Value("int64"),
71
+ "repo_owner": datasets.Value("string"),
72
+ "rank": datasets.Value("int64"),
73
+ "date": datasets.Value("string"),
74
+ }
75
+ )
76
+ else: # monthly
77
+ features = datasets.Features(
78
+ {
79
+ "month": datasets.Value("string"),
80
+ "rank": datasets.Value("int64"),
81
+ "repository": datasets.Value("string"),
82
+ "repo_owner": datasets.Value("string"),
83
+ "repo_name": datasets.Value("string"),
84
+ "star_count": datasets.Value("int64"),
85
+ "fork_count": datasets.Value("int64"),
86
+ "ranking_appearances": datasets.Value("int64"),
87
+ }
88
+ )
89
+
90
+ return datasets.DatasetInfo(
91
+ description=_DESCRIPTION,
92
+ features=features,
93
+ homepage=_HOMEPAGE,
94
+ license=_LICENSE,
95
+ citation=_CITATION,
96
+ )
97
+
98
+ def _split_generators(self, dl_manager):
99
+ urls = _URLS[self.config.name]
100
+ data_file = dl_manager.download_and_extract(urls)
101
+
102
+ return [
103
+ datasets.SplitGenerator(
104
+ name=datasets.Split.TRAIN,
105
+ gen_kwargs={
106
+ "filepath": data_file,
107
+ },
108
+ ),
109
+ ]
110
+
111
+ def _generate_examples(self, filepath):
112
+ """Yields examples."""
113
+ with open(filepath, encoding="utf-8") as f:
114
+ reader = csv.DictReader(f)
115
+ for idx, row in enumerate(reader):
116
+ if self.config.name == "full":
117
+ yield idx, {
118
+ "name": row["name"],
119
+ "star_count": int(row["star_count"]) if row["star_count"] else 0,
120
+ "fork_count": int(row["fork_count"]) if row["fork_count"] else 0,
121
+ "repo_owner": row["repo_owner"],
122
+ "rank": int(row["rank"]) if row["rank"] else 0,
123
+ "date": row["date"],
124
+ }
125
+ else: # monthly
126
+ yield idx, {
127
+ "month": row["month"],
128
+ "rank": int(row["rank"]),
129
+ "repository": row["repository"],
130
+ "repo_owner": row["repo_owner"],
131
+ "repo_name": row["repo_name"],
132
+ "star_count": int(row["star_count"]) if row["star_count"] else 0,
133
+ "fork_count": int(row["fork_count"]) if row["fork_count"] else 0,
134
+ "ranking_appearances": int(row["ranking_appearances"]),
135
+ }