Commit
•
e9388ba
1
Parent(s):
20259a9
add dataset script and documentation
Browse files
README.md
CHANGED
@@ -1,3 +1,50 @@
|
|
1 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
license: apache-2.0
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
languages:
|
3 |
+
- ha
|
4 |
+
- so
|
5 |
+
- sw
|
6 |
+
- yo
|
7 |
+
|
8 |
+
mutilinguality:
|
9 |
+
- multilingual
|
10 |
+
|
11 |
+
task-categories:
|
12 |
+
- text-retrieval
|
13 |
+
|
14 |
license: apache-2.0
|
15 |
+
|
16 |
+
viewer: true
|
17 |
---
|
18 |
+
|
19 |
+
# Dataset Summary
|
20 |
+
|
21 |
+
CIRAL is a collection for cross-lingual information retrieval research across four (4) African languages. The collection comprises English queries and query-passage relevance judgements manually annotated by native speakers.
|
22 |
+
|
23 |
+
This dataset stores passages which have been culled from news websites for CIRAL.
|
24 |
+
|
25 |
+
## Dataset Structure
|
26 |
+
|
27 |
+
This dataset is configured by language. An example of a passage data entry is
|
28 |
+
|
29 |
+
```json
|
30 |
+
{
|
31 |
+
'docid': 'DOCID#0#0',
|
32 |
+
'title': 'This is the title of a sample passage',
|
33 |
+
'text': 'This is the content of a sample passage',
|
34 |
+
'url': 'https:/\/\this-is-a-sample-url.com'
|
35 |
+
}
|
36 |
+
```
|
37 |
+
|
38 |
+
## Load Dataset
|
39 |
+
|
40 |
+
An example to load the dataset
|
41 |
+
|
42 |
+
```python
|
43 |
+
language = "hausa"
|
44 |
+
|
45 |
+
dataset = load_dataset("castorini/ciral-corpus", language)
|
46 |
+
```
|
47 |
+
|
48 |
+
## Citation
|
49 |
+
|
50 |
+
...
|
ciral.py
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
from string import Template
|
3 |
+
|
4 |
+
import datasets
|
5 |
+
|
6 |
+
_CITATION = "" # TODO: @theyorubayesian
|
7 |
+
_DESCRIPTION = \
|
8 |
+
"""
|
9 |
+
A collection of passages culled from news websites for Cross-Lingual Information Retrieval for African Languages.
|
10 |
+
"""
|
11 |
+
_HOMEPAGE = "https://github.com/castorini/ciral"
|
12 |
+
_LICENSE = "Apache License 2.0"
|
13 |
+
_VERSION = "1.0.0"
|
14 |
+
_LANGUAGES = [
|
15 |
+
"hausa",
|
16 |
+
"somali",
|
17 |
+
"swahili",
|
18 |
+
"yoruba",
|
19 |
+
"combined"
|
20 |
+
]
|
21 |
+
_DATASET_URL = Template("./passages-v1.0/${language}_passages.jsonl")
|
22 |
+
|
23 |
+
|
24 |
+
class CiralPassages(datasets.GeneratorBasedBuilder):
|
25 |
+
BUILDER_CONFIGS = [
|
26 |
+
datasets.BuilderConfig(
|
27 |
+
version=datasets.Version(_VERSION),
|
28 |
+
name=language,
|
29 |
+
description=f"CIRAL passages for language: {language}"
|
30 |
+
) for language in _LANGUAGES
|
31 |
+
]
|
32 |
+
DEFAULT_CONFIG_NAME = "combined"
|
33 |
+
|
34 |
+
def _info(self):
|
35 |
+
return datasets.DatasetInfo(
|
36 |
+
description=_DESCRIPTION,
|
37 |
+
citation=_CITATION,
|
38 |
+
features=datasets.Features({
|
39 |
+
"docid": datasets.Value("string"),
|
40 |
+
"title": datasets.Value("string"),
|
41 |
+
"text": datasets.Value("string"),
|
42 |
+
"url": datasets.Value("string")
|
43 |
+
}),
|
44 |
+
homepage=_HOMEPAGE,
|
45 |
+
license=_LICENSE
|
46 |
+
)
|
47 |
+
|
48 |
+
def _split_generators(self, dl_manager: datasets.DownloadManager):
|
49 |
+
language = self.config.name
|
50 |
+
if language == "combined":
|
51 |
+
language_file = dl_manager.download_and_extract({
|
52 |
+
_language: _DATASET_URL.substitute(language=_language)
|
53 |
+
for _language in _LANGUAGES[:-1]
|
54 |
+
})
|
55 |
+
|
56 |
+
splits = [
|
57 |
+
datasets.SplitGenerator(
|
58 |
+
name=_language, gen_kwargs={"filepath": language_file[_language]}
|
59 |
+
) for _language in _LANGUAGES[:-1]
|
60 |
+
]
|
61 |
+
return splits
|
62 |
+
else:
|
63 |
+
language_file = dl_manager.download_and_extract(
|
64 |
+
_DATASET_URL.substitute(language=language))
|
65 |
+
|
66 |
+
splits = [
|
67 |
+
datasets.SplitGenerator(
|
68 |
+
name="train",
|
69 |
+
gen_kwargs={"filepath": language_file}
|
70 |
+
)
|
71 |
+
]
|
72 |
+
return splits
|
73 |
+
|
74 |
+
def _generate_examples(self, filepath: str):
|
75 |
+
with open(filepath, encoding="utf-8") as f:
|
76 |
+
for line in f:
|
77 |
+
data = json.loads(line)
|
78 |
+
yield data["docid"], data
|