Albert Villanova del Moral
commited on
Commit
•
75ee112
1
Parent(s):
1ac303e
Add date argument
Browse files- open_access.py +9 -8
open_access.py
CHANGED
@@ -67,19 +67,20 @@ _BASELINE_RANGES = {
|
|
67 |
class OpenAccessConfig(datasets.BuilderConfig):
|
68 |
"""BuilderConfig for the PMC Open Access Subset."""
|
69 |
|
70 |
-
def __init__(self, subsets=None, **kwargs):
|
71 |
"""BuilderConfig for the PMC Open Access Subset.
|
72 |
|
73 |
Args:
|
74 |
-
|
75 |
-
|
|
|
76 |
"""
|
77 |
subsets = [subsets] if isinstance(subsets, str) else subsets
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
)
|
82 |
self.subsets = subsets if self.name != "all" else list(_SUBSETS.keys())
|
|
|
83 |
|
84 |
|
85 |
class OpenAccess(datasets.GeneratorBasedBuilder):
|
@@ -123,7 +124,7 @@ class OpenAccess(datasets.GeneratorBasedBuilder):
|
|
123 |
for baseline in baselines
|
124 |
]
|
125 |
# Incremental
|
126 |
-
date_delta = datetime.date.
|
127 |
incremental_dates = [
|
128 |
(datetime.date.fromisoformat(_BASELINE_DATE) + datetime.timedelta(days=i + 1)).isoformat()
|
129 |
for i in range(date_delta.days)
|
|
|
67 |
class OpenAccessConfig(datasets.BuilderConfig):
|
68 |
"""BuilderConfig for the PMC Open Access Subset."""
|
69 |
|
70 |
+
def __init__(self, date=_BASELINE_DATE, subsets=None, **kwargs):
|
71 |
"""BuilderConfig for the PMC Open Access Subset.
|
72 |
|
73 |
Args:
|
74 |
+
date (`str`, default _BASELINE_DATE) : Up to date, in ISO format. Pass 'latest' for latest date.
|
75 |
+
subsets ('all' or list of {'commercial', 'non_commercial', 'other'}): List of subsets to load.
|
76 |
+
**kwargs: Keyword arguments forwarded to `BuilderConfig`.
|
77 |
"""
|
78 |
subsets = [subsets] if isinstance(subsets, str) else subsets
|
79 |
+
date = datetime.date.today().isoformat() if date=="latest" else date
|
80 |
+
name = date + "." + "+".join(subsets)
|
81 |
+
super().__init__(name=name, **kwargs)
|
|
|
82 |
self.subsets = subsets if self.name != "all" else list(_SUBSETS.keys())
|
83 |
+
self.date = date
|
84 |
|
85 |
|
86 |
class OpenAccess(datasets.GeneratorBasedBuilder):
|
|
|
124 |
for baseline in baselines
|
125 |
]
|
126 |
# Incremental
|
127 |
+
date_delta = datetime.date.fromisoformat(self.config.date) - datetime.date.fromisoformat(_BASELINE_DATE)
|
128 |
incremental_dates = [
|
129 |
(datetime.date.fromisoformat(_BASELINE_DATE) + datetime.timedelta(days=i + 1)).isoformat()
|
130 |
for i in range(date_delta.days)
|