Datasets:

Modalities:
Text
Formats:
json
Languages:
French
ArXiv:
Libraries:
Datasets
pandas
License:
mciancone commited on
Commit
c51a95d
·
1 Parent(s): df4c754

Upload alloprof.py

Browse files
Files changed (1) hide show
  1. alloprof.py +119 -0
alloprof.py ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ """Alloprof: a new French question-answer education dataset and its use in an information retrieval case study"""
15
+ import json
16
+ import datasets
17
+
18
+
19
+ _CITATION = """\
20
+ @misc{lef23,
21
+ doi = {10.48550/ARXIV.2302.07738},
22
+ url = {https://arxiv.org/abs/2302.07738},
23
+ author = {Lefebvre-Brossard, Antoine and Gazaille, Stephane and Desmarais, Michel C.},
24
+ keywords = {Computation and Language (cs.CL), Information Retrieval (cs.IR), Machine Learning (cs.LG), FOS: Computer and information sciences, FOS: Computer and information sciences},
25
+ title = {Alloprof: a new French question-answer education dataset and its use in an information retrieval case study},
26
+ publisher = {arXiv},
27
+ year = {2023},
28
+ copyright = {Creative Commons Attribution Non Commercial Share Alike 4.0 International}
29
+ }
30
+ """
31
+
32
+ _DESCRIPTION = """\
33
+ This is a re-edit from the Alloprof dataset (which can be found here : https://huggingface.co/datasets/antoinelb7/alloprof).
34
+
35
+ For more information about the data source and the features, please refer to the original dataset card made by the authors, along with their paper available here : https://arxiv.org/abs/2302.07738
36
+
37
+ This re-edition of the dataset has been made for easier usage in the MTEB benchmarking pipeline. (https://huggingface.co/spaces/mteb/leaderboard). It is a filtered version of the original dataset, in a more ready-to-use format.
38
+ """
39
+
40
+ _HOMEPAGE = "https://huggingface.co/datasets/antoinelb7/alloprof"
41
+ _LICENSE = "Creative Commons Attribution Non Commercial Share Alike 4.0 International"
42
+ _URLS = {
43
+ "documents": "https://huggingface.co/datasets/lyon-nlp/alloprof/resolve/main/documents.json",
44
+ "queries": "https://huggingface.co/datasets/lyon-nlp/alloprof/resolve/main/queries.json"
45
+ }
46
+
47
+ class Alloprof(datasets.GeneratorBasedBuilder):
48
+ """Alloprof: a new French question-answer education dataset and its use in an information retrieval case study"""
49
+
50
+ VERSION = datasets.Version("1.0.0")
51
+ BUILDER_CONFIGS = [
52
+ datasets.BuilderConfig(name="documents", version=VERSION, description="Corpus of documents from the Alloprof website"),
53
+ datasets.BuilderConfig(name="queries", version=VERSION, description="Corpus of queries from students"),
54
+ ]
55
+ DEFAULT_CONFIG_NAME = "documents"
56
+
57
+ def _info(self):
58
+ if self.config.name == "documents":
59
+ features = {
60
+ "uuid": datasets.Value("string"),
61
+ "title": datasets.Value("string"),
62
+ "topic": datasets.Value("string"),
63
+ "text": datasets.Value("string"),
64
+ }
65
+ elif self.config.name == "queries":
66
+ features = {
67
+ "id": datasets.Value("int32"),
68
+ "text": datasets.Value("string"),
69
+ "answer": datasets.Value("string"),
70
+ "relevant": datasets.Sequence(datasets.Value("string")),
71
+ "subject": datasets.Value("string"),
72
+ }
73
+ else:
74
+ raise ValueError(f"Unknown config name {self.config.name}")
75
+ return datasets.DatasetInfo(
76
+ description=_DESCRIPTION,
77
+ features=datasets.Features(features),
78
+ supervised_keys=None,
79
+ homepage=_HOMEPAGE,
80
+ license=_LICENSE,
81
+ citation=_CITATION,
82
+ )
83
+
84
+ def _split_generators(self, dl_manager):
85
+ if self.config.name == "documents":
86
+ dl_path = dl_manager.download_and_extract(_URLS["documents"])
87
+ return [datasets.SplitGenerator(name="documents", gen_kwargs={"filepath": dl_path})]
88
+ elif self.config.name == "queries":
89
+ dl_paths = dl_manager.download_and_extract(_URLS["queries"])
90
+ return [datasets.SplitGenerator(name="queries", gen_kwargs={"filepath": dl_paths})]
91
+ else:
92
+ raise ValueError(f"Unknown config name {self.config.name}")
93
+
94
+
95
+ def _generate_examples(self, filepath):
96
+ if self.config.name in ["documents", "queries"]:
97
+ with open(filepath, encoding="utf-8") as f:
98
+ data = json.load(f)
99
+ for key, row in enumerate(data):
100
+ if self.config.name == "documents":
101
+ features = {
102
+ "uuid": row["uuid"],
103
+ "title": row["title"],
104
+ "topic": row["topic"],
105
+ "text": row["text"],
106
+ }
107
+ elif self.config.name == "queries":
108
+ features = {
109
+ "id": row["id"],
110
+ "text": row["text"],
111
+ "answer": row["answer"],
112
+ "relevant": row["relevant"],
113
+ "subject": row["subject"],
114
+ }
115
+ else:
116
+ raise ValueError(f"Unknown config name {self.config.name}")
117
+ yield key, features
118
+ else:
119
+ raise ValueError(f"Unknown config name {self.config.name}")