Datasets:

Modalities:
Text
Formats:
parquet
Sub-tasks:
extractive-qa
Languages:
Catalan
ArXiv:
Libraries:
Datasets
pandas
License:
AnnaSallesRius commited on
Commit
22eb5c0
1 Parent(s): bb78be8

Upload 4 files

Browse files
Files changed (4) hide show
  1. OLD/catalanqa.py +110 -0
  2. OLD/dev.json +3 -0
  3. OLD/test.json +3 -0
  4. OLD/train.json +3 -0
OLD/catalanqa.py ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """CatalanQA Dataset."""
2
+ # Loading script for the CatalanQA dataset.
3
+ import json
4
+
5
+ import datasets
6
+
7
+ logger = datasets.logging.get_logger(__name__)
8
+
9
+ _CITATION = """\
10
+ None
11
+ """
12
+
13
+ _DESCRIPTION = """\
14
+ CatalanQA: an extractive QA dataset from original Catalan Sources: Wikipedia and VilaWeb newswire.
15
+
16
+ It is an aggregation and balancing of 2 previous datasets: VilaQUAD and ViquiQUAD, which were described in
17
+
18
+ This dataset can be used to build extractive-QA and Language Models.
19
+
20
+ Splts have been balanced by kind of question, and unlike other datasets like SQUAD, it only contains, per record, one question and one answer for each context, although the contexts can repeat multiple times.
21
+
22
+ - test.json contains 2135 question/answer pairs
23
+
24
+ - train.json contains 17135 question/answer pairs
25
+
26
+ - dev.json contains 2157 question/answer pairs
27
+
28
+ Funded by the Generalitat de Catalunya, Departament de Polítiques Digitals i Administració Pública (AINA),
29
+ and Plan de Impulso de las Tecnologías del Lenguaje (Plan TL).
30
+ """
31
+
32
+ _HOMEPAGE = ""
33
+
34
+ _URL = "https://huggingface.co/datasets/projecte-aina/catalanqa/resolve/main/"
35
+ _TRAINING_FILE = "train.json"
36
+ _DEV_FILE = "dev.json"
37
+ _TEST_FILE = "test.json"
38
+
39
+
40
+ class CatalanQA(datasets.GeneratorBasedBuilder):
41
+ """CatalanQA Dataset."""
42
+
43
+ VERSION = datasets.Version("1.0.1")
44
+
45
+ def _info(self):
46
+ return datasets.DatasetInfo(
47
+ description=_DESCRIPTION,
48
+ features=datasets.Features(
49
+ {
50
+ "id": datasets.Value("string"),
51
+ "title": datasets.Value("string"),
52
+ "context": datasets.Value("string"),
53
+ "question": datasets.Value("string"),
54
+ "answers": [
55
+ {
56
+ "text": datasets.Value("string"),
57
+ "answer_start": datasets.Value("int32"),
58
+ }
59
+ ],
60
+ }
61
+ ),
62
+ # No default supervised_keys (as we have to pass both question
63
+ # and context as input).
64
+ supervised_keys=None,
65
+ homepage=_HOMEPAGE,
66
+ citation=_CITATION,
67
+ )
68
+
69
+ def _split_generators(self, dl_manager):
70
+ """Returns SplitGenerators."""
71
+ urls_to_download = {
72
+ "train": f"{_URL}{_TRAINING_FILE}",
73
+ "dev": f"{_URL}{_DEV_FILE}",
74
+ "test": f"{_URL}{_TEST_FILE}",
75
+ }
76
+ downloaded_files = dl_manager.download(urls_to_download)
77
+
78
+ return [
79
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}),
80
+ datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": downloaded_files["dev"]}),
81
+ datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloaded_files["test"]}),
82
+ ]
83
+
84
+ def _generate_examples(self, filepath):
85
+ """This function returns the examples in the raw (text) form."""
86
+ logger.info("generating examples from = %s", filepath)
87
+ with open(filepath, encoding="utf-8") as f:
88
+ catalanqa = json.load(f)
89
+ for article in catalanqa["data"]:
90
+ title = article.get("title", "").strip()
91
+ for paragraph in article["paragraphs"]:
92
+ context = paragraph["context"].strip()
93
+ for qa in paragraph["qas"]:
94
+ question = qa["question"].strip()
95
+ id_ = qa["id"]
96
+ # answer_starts = [answer["answer_start"] for answer in qa["answers"]]
97
+ # answers = [answer["text"].strip() for answer in qa["answers"]]
98
+ text = qa["answers"][0]["text"]
99
+ answer_start = qa["answers"][0]["answer_start"]
100
+
101
+ # Features currently used are "context", "question", and "answers".
102
+ # Others are extracted here for the ease of future expansions.
103
+ yield id_, {
104
+ "title": title,
105
+ "context": context,
106
+ "question": question,
107
+ "id": id_,
108
+ "answers": [{"text": text, "answer_start": answer_start}],
109
+ }
110
+
OLD/dev.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c7c6801fb921e889b0a0b2aa1181659598f2ed074d4fcd4684ba61e557e3420f
3
+ size 2951660
OLD/test.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:733e7247aacda187da67cc1506311aaa8bc3c30401a13ae48df61b1e27af1e57
3
+ size 2899131
OLD/train.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b5033de1380c7fb176d51bda23923997858bed49ac371de79b8a069808b305ad
3
+ size 23437891