Datasets:

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

update with error management

Browse files
Files changed (1) hide show
  1. alloprof.py +10 -6
alloprof.py CHANGED
@@ -37,11 +37,12 @@ For more information about the data source and the features, please refer to the
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):
@@ -52,6 +53,9 @@ class Alloprof(datasets.GeneratorBasedBuilder):
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):
@@ -71,7 +75,7 @@ class Alloprof(datasets.GeneratorBasedBuilder):
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),
@@ -89,7 +93,7 @@ class Alloprof(datasets.GeneratorBasedBuilder):
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):
@@ -113,7 +117,7 @@ class Alloprof(datasets.GeneratorBasedBuilder):
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}")
 
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
+ _SPLITS = ["documents", "queries"]
41
  _HOMEPAGE = "https://huggingface.co/datasets/antoinelb7/alloprof"
42
  _LICENSE = "Creative Commons Attribution Non Commercial Share Alike 4.0 International"
43
  _URLS = {
44
+ split: f"https://huggingface.co/datasets/lyon-nlp/alloprof/resolve/main/{split}.json"\
45
+ for split in _SPLITS
46
  }
47
 
48
  class Alloprof(datasets.GeneratorBasedBuilder):
 
53
  datasets.BuilderConfig(name="documents", version=VERSION, description="Corpus of documents from the Alloprof website"),
54
  datasets.BuilderConfig(name="queries", version=VERSION, description="Corpus of queries from students"),
55
  ]
56
+
57
+ # Avoid setting default config so that an error is raised asking the user
58
+ # to specify the piece of the dataset wanted
59
  DEFAULT_CONFIG_NAME = "documents"
60
 
61
  def _info(self):
 
75
  "subject": datasets.Value("string"),
76
  }
77
  else:
78
+ raise ValueError(f"Please specify a valid config name : {_SPLITS}")
79
  return datasets.DatasetInfo(
80
  description=_DESCRIPTION,
81
  features=datasets.Features(features),
 
93
  dl_paths = dl_manager.download_and_extract(_URLS["queries"])
94
  return [datasets.SplitGenerator(name="queries", gen_kwargs={"filepath": dl_paths})]
95
  else:
96
+ raise ValueError(f"Please specify a valid config name : {_SPLITS}")
97
 
98
 
99
  def _generate_examples(self, filepath):
 
117
  "subject": row["subject"],
118
  }
119
  else:
120
+ raise ValueError(f"Please specify a valid config name : {_SPLITS}")
121
  yield key, features
122
  else:
123
+ raise ValueError(f"Please specify a valid config name : {_SPLITS}")