Trying adding a dl_manager call
Browse files- sefaria.py +14 -8
sefaria.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import os
|
2 |
import pandas as pd
|
|
|
3 |
|
4 |
import datasets
|
5 |
|
@@ -27,7 +28,7 @@ _HOMEPAGE = "https://github.com/Sefaria/Sefaria-Export"
|
|
27 |
_LICENSE = "Each text is licensed separately, so there is no overall license for this repository."
|
28 |
|
29 |
class Sefaria(datasets.GeneratorBasedBuilder):
|
30 |
-
VERSION = datasets.Version("1.0.
|
31 |
|
32 |
BUILDER_CONFIGS = [
|
33 |
datasets.BuilderConfig(name="english", version=VERSION, description="This configuration contains only English texts"),
|
@@ -51,16 +52,21 @@ class Sefaria(datasets.GeneratorBasedBuilder):
|
|
51 |
license=_LICENSE,
|
52 |
citation=_CITATION,
|
53 |
)
|
|
|
|
|
|
|
|
|
|
|
54 |
|
55 |
def _split_generators(self, dl_manager):
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
filepaths = [os.path.join(data_dir, f) for f in os.listdir(data_dir) if f.endswith("_english.parquet")]
|
60 |
-
elif self.config.name == "hebrew":
|
61 |
-
filepaths = [os.path.join(data_dir, f) for f in os.listdir(data_dir) if f.endswith("_hebrew.parquet")]
|
62 |
else:
|
63 |
-
|
|
|
|
|
|
|
64 |
|
65 |
print(f"Filepaths found: {filepaths}") # Add this line to print the filepaths
|
66 |
|
|
|
1 |
import os
|
2 |
import pandas as pd
|
3 |
+
import glob
|
4 |
|
5 |
import datasets
|
6 |
|
|
|
28 |
_LICENSE = "Each text is licensed separately, so there is no overall license for this repository."
|
29 |
|
30 |
class Sefaria(datasets.GeneratorBasedBuilder):
|
31 |
+
VERSION = datasets.Version("1.0.3")
|
32 |
|
33 |
BUILDER_CONFIGS = [
|
34 |
datasets.BuilderConfig(name="english", version=VERSION, description="This configuration contains only English texts"),
|
|
|
52 |
license=_LICENSE,
|
53 |
citation=_CITATION,
|
54 |
)
|
55 |
+
data_urls = {
|
56 |
+
"english": "https://huggingface.co/datasets/mehdie/sefaria/raw/main/data/*_english.parquet",
|
57 |
+
"hebrew": "https://huggingface.co/datasets/mehdie/sefaria/raw/main/data/*_hebrew.parquet",
|
58 |
+
"all": "https://huggingface.co/datasets/mehdie/sefaria/raw/main/data/*.parquet"
|
59 |
+
}
|
60 |
|
61 |
def _split_generators(self, dl_manager):
|
62 |
+
# Download and extract the dataset files
|
63 |
+
if self.config.name in ["english", "hebrew"]:
|
64 |
+
data_dir = dl_manager.download_and_extract(data_urls[self.config.name])
|
|
|
|
|
|
|
65 |
else:
|
66 |
+
data_dir = dl_manager.download_and_extract(data_urls["all"])
|
67 |
+
|
68 |
+
# Find the files in the extracted directory
|
69 |
+
filepaths = glob.glob(os.path.join(data_dir, "*.parquet"))
|
70 |
|
71 |
print(f"Filepaths found: {filepaths}") # Add this line to print the filepaths
|
72 |
|