Commit ·
a6639cd
1
Parent(s): f5df226
Create v4design.py
Browse files- v4design.py +47 -0
v4design.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import csv
|
| 2 |
+
import datasets
|
| 3 |
+
import os
|
| 4 |
+
|
| 5 |
+
_DESCRIPTION = "example"
|
| 6 |
+
|
| 7 |
+
_HOMEPAGE = "TODO"
|
| 8 |
+
|
| 9 |
+
_LICENSE = "TODO"
|
| 10 |
+
|
| 11 |
+
_URL = "https://zenodo.org/record/4896487/files/V4Design_Europeana_style_dataset.csv?download=1"
|
| 12 |
+
|
| 13 |
+
class V4Design(datasets.GeneratorBasedBuilder):
|
| 14 |
+
"""TODO"""
|
| 15 |
+
|
| 16 |
+
VERSION = datasets.Version("1.1.0")
|
| 17 |
+
|
| 18 |
+
def _info(self):
|
| 19 |
+
features = datasets.Features(
|
| 20 |
+
{"id": datasets.Value("string"),
|
| 21 |
+
"url": datasets.Value("string"),
|
| 22 |
+
"uri": datasets.Value("string"),
|
| 23 |
+
"style":datasets.ClassLabel(names=['Rococo', 'Baroque', 'Other']),
|
| 24 |
+
"rights": datasets.Value("string"),}
|
| 25 |
+
)
|
| 26 |
+
return datasets.DatasetInfo(
|
| 27 |
+
description=_DESCRIPTION,
|
| 28 |
+
features=features,
|
| 29 |
+
homepage=_HOMEPAGE,
|
| 30 |
+
license=_LICENSE,
|
| 31 |
+
citation="TODO",
|
| 32 |
+
)
|
| 33 |
+
|
| 34 |
+
def _split_generators(self, dl_manager):
|
| 35 |
+
csv_file = dl_manager.download_and_extract(_URL)
|
| 36 |
+
return [
|
| 37 |
+
datasets.SplitGenerator(
|
| 38 |
+
name=datasets.Split.TRAIN,
|
| 39 |
+
gen_kwargs={"csv_file": csv_file}
|
| 40 |
+
),
|
| 41 |
+
]
|
| 42 |
+
|
| 43 |
+
def _generate_examples(self, csv_file):
|
| 44 |
+
with open(csv_file, encoding="utf-8") as f:
|
| 45 |
+
data = csv.DictReader(f)
|
| 46 |
+
for row, item in enumerate(data):
|
| 47 |
+
yield row, {"id": item['id'],"url": item['url'], "uri": item['uri'], "style":item['style'], "rights": item['rights']}
|