FragDBnet commited on
Commit
ca5bd1a
·
verified ·
1 Parent(s): 81443bb

Remove unsupported loading script

Browse files
Files changed (1) hide show
  1. fragrance-database.py +0 -144
fragrance-database.py DELETED
@@ -1,144 +0,0 @@
1
- """FragDB Fragrance Database - Custom loading script for pipe-delimited CSV files."""
2
-
3
- import csv
4
- import datasets
5
-
6
- _DESCRIPTION = """
7
- FragDB is the most comprehensive structured fragrance database available.
8
- This sample contains 10 fragrances with related brands and perfumers.
9
- """
10
-
11
- _HOMEPAGE = "https://fragdb.net"
12
- _LICENSE = "MIT"
13
-
14
- _URLS = {
15
- "fragrances": "fragrances.csv",
16
- "brands": "brands.csv",
17
- "perfumers": "perfumers.csv",
18
- }
19
-
20
-
21
- class FragranceDatabase(datasets.GeneratorBasedBuilder):
22
- """FragDB Fragrance Database."""
23
-
24
- VERSION = datasets.Version("2.0.0")
25
-
26
- BUILDER_CONFIGS = [
27
- datasets.BuilderConfig(name="fragrances", version=VERSION, description="Fragrance data"),
28
- datasets.BuilderConfig(name="brands", version=VERSION, description="Brand data"),
29
- datasets.BuilderConfig(name="perfumers", version=VERSION, description="Perfumer data"),
30
- datasets.BuilderConfig(name="all", version=VERSION, description="All tables"),
31
- ]
32
-
33
- DEFAULT_CONFIG_NAME = "all"
34
-
35
- def _info(self):
36
- if self.config.name == "fragrances":
37
- features = datasets.Features({
38
- "pid": datasets.Value("int64"),
39
- "url": datasets.Value("string"),
40
- "brand": datasets.Value("string"),
41
- "name": datasets.Value("string"),
42
- "year": datasets.Value("int64"),
43
- "gender": datasets.Value("string"),
44
- "collection": datasets.Value("string"),
45
- "main_photo": datasets.Value("string"),
46
- "info_card": datasets.Value("string"),
47
- "user_photoes": datasets.Value("string"),
48
- "accords": datasets.Value("string"),
49
- "notes_pyramid": datasets.Value("string"),
50
- "perfumers": datasets.Value("string"),
51
- "description": datasets.Value("string"),
52
- "rating": datasets.Value("string"),
53
- "appreciation": datasets.Value("string"),
54
- "price_value": datasets.Value("string"),
55
- "ownership": datasets.Value("string"),
56
- "gender_votes": datasets.Value("string"),
57
- "longevity": datasets.Value("string"),
58
- "sillage": datasets.Value("string"),
59
- "season": datasets.Value("string"),
60
- "time_of_day": datasets.Value("string"),
61
- "by_designer": datasets.Value("string"),
62
- "in_collection": datasets.Value("string"),
63
- "reminds_of": datasets.Value("string"),
64
- "also_like": datasets.Value("string"),
65
- "news_ids": datasets.Value("string"),
66
- })
67
- elif self.config.name == "brands":
68
- features = datasets.Features({
69
- "id": datasets.Value("string"),
70
- "name": datasets.Value("string"),
71
- "url": datasets.Value("string"),
72
- "logo_url": datasets.Value("string"),
73
- "country": datasets.Value("string"),
74
- "main_activity": datasets.Value("string"),
75
- "website": datasets.Value("string"),
76
- "parent_company": datasets.Value("string"),
77
- "description": datasets.Value("string"),
78
- "brand_count": datasets.Value("int64"),
79
- })
80
- elif self.config.name == "perfumers":
81
- features = datasets.Features({
82
- "id": datasets.Value("string"),
83
- "name": datasets.Value("string"),
84
- "url": datasets.Value("string"),
85
- "photo_url": datasets.Value("string"),
86
- "status": datasets.Value("string"),
87
- "company": datasets.Value("string"),
88
- "also_worked": datasets.Value("string"),
89
- "education": datasets.Value("string"),
90
- "web": datasets.Value("string"),
91
- "perfumes_count": datasets.Value("int64"),
92
- "biography": datasets.Value("string"),
93
- })
94
- else: # all
95
- features = datasets.Features({
96
- "table": datasets.Value("string"),
97
- "data": datasets.Value("string"),
98
- })
99
-
100
- return datasets.DatasetInfo(
101
- description=_DESCRIPTION,
102
- features=features,
103
- homepage=_HOMEPAGE,
104
- license=_LICENSE,
105
- )
106
-
107
- def _split_generators(self, dl_manager):
108
- if self.config.name == "all":
109
- return [
110
- datasets.SplitGenerator(
111
- name="fragrances",
112
- gen_kwargs={"filepath": dl_manager.download_and_extract(_URLS["fragrances"]), "table": "fragrances"},
113
- ),
114
- datasets.SplitGenerator(
115
- name="brands",
116
- gen_kwargs={"filepath": dl_manager.download_and_extract(_URLS["brands"]), "table": "brands"},
117
- ),
118
- datasets.SplitGenerator(
119
- name="perfumers",
120
- gen_kwargs={"filepath": dl_manager.download_and_extract(_URLS["perfumers"]), "table": "perfumers"},
121
- ),
122
- ]
123
- else:
124
- return [
125
- datasets.SplitGenerator(
126
- name="train",
127
- gen_kwargs={"filepath": dl_manager.download_and_extract(_URLS[self.config.name]), "table": self.config.name},
128
- ),
129
- ]
130
-
131
- def _generate_examples(self, filepath, table):
132
- with open(filepath, encoding="utf-8") as f:
133
- reader = csv.DictReader(f, delimiter="|")
134
- for idx, row in enumerate(reader):
135
- # Convert numeric fields
136
- if table == "fragrances":
137
- row["pid"] = int(row["pid"]) if row.get("pid") else 0
138
- row["year"] = int(row["year"]) if row.get("year") else 0
139
- elif table == "brands":
140
- row["brand_count"] = int(row["brand_count"]) if row.get("brand_count") else 0
141
- elif table == "perfumers":
142
- row["perfumes_count"] = int(row["perfumes_count"]) if row.get("perfumes_count") else 0
143
-
144
- yield idx, row