Delete wikiculture.py
Browse files- wikiculture.py +0 -57
wikiculture.py
DELETED
|
@@ -1,57 +0,0 @@
|
|
| 1 |
-
import datasets
|
| 2 |
-
|
| 3 |
-
class WikiCultureConfig(datasets.BuilderConfig):
|
| 4 |
-
def __init__(self, data_files, **kwargs):
|
| 5 |
-
super().__init__(**kwargs)
|
| 6 |
-
self.data_files = data_files
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
class WikiCulture(datasets.GeneratorBasedBuilder):
|
| 10 |
-
VERSION = datasets.Version("1.0.0")
|
| 11 |
-
|
| 12 |
-
BUILDER_CONFIGS = [
|
| 13 |
-
WikiCultureConfig(
|
| 14 |
-
name="all",
|
| 15 |
-
description="All cultures combined",
|
| 16 |
-
data_files=[
|
| 17 |
-
"AF.parquet", "AS.parquet", "AU.parquet", "CH.parquet",
|
| 18 |
-
"EU.parquet", "LA.parquet", "ME.parquet", "NA.parquet",
|
| 19 |
-
],
|
| 20 |
-
),
|
| 21 |
-
WikiCultureConfig("AF", "Africa", ["AF.parquet"]),
|
| 22 |
-
WikiCultureConfig("AS", "Asia", ["AS.parquet"]),
|
| 23 |
-
WikiCultureConfig("AU", "Australia & Oceania", ["AU.parquet"]),
|
| 24 |
-
WikiCultureConfig("CH", "China", ["CH.parquet"]),
|
| 25 |
-
WikiCultureConfig("EU", "Europe", ["EU.parquet"]),
|
| 26 |
-
WikiCultureConfig("LA", "Latin America", ["LA.parquet"]),
|
| 27 |
-
WikiCultureConfig("ME", "Middle East", ["ME.parquet"]),
|
| 28 |
-
WikiCultureConfig("NA", "North America", ["NA.parquet"]),
|
| 29 |
-
]
|
| 30 |
-
|
| 31 |
-
def _info(self):
|
| 32 |
-
return datasets.DatasetInfo(
|
| 33 |
-
features=datasets.Features({
|
| 34 |
-
"page_title": datasets.Value("string"),
|
| 35 |
-
"qitem": datasets.Value("string"),
|
| 36 |
-
"bucket_geo": datasets.Value("string"),
|
| 37 |
-
"wiki_id": datasets.Value("int64"),
|
| 38 |
-
"text": datasets.Value("string"),
|
| 39 |
-
})
|
| 40 |
-
)
|
| 41 |
-
|
| 42 |
-
def _split_generators(self, dl_manager):
|
| 43 |
-
return [
|
| 44 |
-
datasets.SplitGenerator(
|
| 45 |
-
name=datasets.Split.TRAIN,
|
| 46 |
-
gen_kwargs={"files": self.config.data_files},
|
| 47 |
-
)
|
| 48 |
-
]
|
| 49 |
-
|
| 50 |
-
def _generate_examples(self, files):
|
| 51 |
-
import pyarrow.parquet as pq
|
| 52 |
-
idx = 0
|
| 53 |
-
for file in files:
|
| 54 |
-
table = pq.read_table(file)
|
| 55 |
-
for row in table.to_pylist():
|
| 56 |
-
yield idx, row
|
| 57 |
-
idx += 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|