Datasets:
Update README.md
Browse files
README.md
CHANGED
@@ -63,7 +63,23 @@ This dataset card aims to be a base template for new datasets. It has been gener
|
|
63 |
|
64 |
### Direct Use
|
65 |
|
66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
|
68 |
[More Information Needed]
|
69 |
|
|
|
63 |
|
64 |
### Direct Use
|
65 |
|
66 |
+
```python
|
67 |
+
from typing import List, Optional
|
68 |
+
from huggingface_hub import list_repo_files, hf_hub_url
|
69 |
+
|
70 |
+
def get_files_for_lang_and_years(languages: List[str], min_year:Optional[int]= None, max_year:Optional[int] = None):
|
71 |
+
files = list_repo_files("biglam/europeana_newspapers",repo_type='dataset')
|
72 |
+
parquet_files = [f for f in files if f.endswith(".parquet")]
|
73 |
+
parquet_files_filtered_for_lang = [f for f in parquet_files if any(lang in f for lang in ['uk', 'fr'])]
|
74 |
+
filtered_files = [f for f in parquet_files if
|
75 |
+
(min_year is None or min_year <= int(f.split('-')[1].split('.')[0])) and
|
76 |
+
(max_year is None or int(f.split('-')[1].split('.')[0]) <= max_year)]
|
77 |
+
return [hf_hub_url("biglam/europeana_newspapers", f, repo_type='dataset') for f in filtered_files]
|
78 |
+
```
|
79 |
+
|
80 |
+
```python
|
81 |
+
ds = load_dataset("parquet", data_files=get_files_for_lang_and_years(['fr']), num_proc=4)
|
82 |
+
```
|
83 |
|
84 |
[More Information Needed]
|
85 |
|