Matej Klemen commited on
Commit
c3ccd8e
1 Parent(s): 0fe11c2

Fix option to load private version of dataset

Browse files
Files changed (2) hide show
  1. dataset_infos.json +1 -1
  2. si_nli.py +26 -6
dataset_infos.json CHANGED
@@ -1 +1 @@
1
- {"default": {"description": "SI-NLI (Slovene Natural Language Inference Dataset) contains 5,937 human-created Slovene sentence pairs \n(premise and hypothesis) that are manually labeled with the labels \"entailment\", \"contradiction\", and \"neutral\". \nThe dataset was created using sentences that appear in the Slovenian reference corpus ccKres. \nAnnotators were tasked to modify the hypothesis in a candidate pair in a way that reflects one of the labels. \nThe dataset is balanced since the annotators created three modifications (entailment, contradiction, neutral) \nfor each candidate sentence pair.\n", "citation": "@misc{sinli,\n title = {Slovene Natural Language Inference Dataset {SI}-{NLI}},\n author = {Klemen, Matej and {\u000b Z}agar, Ale{\u000b s} and {\u000b C}ibej, Jaka and Robnik-{\u000b S}ikonja, Marko},\n url = {http://hdl.handle.net/11356/1707},\n note = {Slovenian language resource repository {CLARIN}.{SI}},\n year = {2022}\n}\n", "homepage": "http://hdl.handle.net/11356/1707", "license": "Creative Commons - Attribution 4.0 International (CC BY 4.0)", "features": {"pair_id": {"dtype": "string", "id": null, "_type": "Value"}, "premise": {"dtype": "string", "id": null, "_type": "Value"}, "hypothesis": {"dtype": "string", "id": null, "_type": "Value"}, "annotation1": {"dtype": "string", "id": null, "_type": "Value"}, "annotator1_id": {"dtype": "string", "id": null, "_type": "Value"}, "annotation2": {"dtype": "string", "id": null, "_type": "Value"}, "annotator2_id": {"dtype": "string", "id": null, "_type": "Value"}, "annotation3": {"dtype": "string", "id": null, "_type": "Value"}, "annotator3_id": {"dtype": "string", "id": null, "_type": "Value"}, "annotation_final": {"dtype": "string", "id": null, "_type": "Value"}, "label": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "si_nli", "config_name": "default", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 1352635, "num_examples": 4392, "dataset_name": "si_nli"}, "validation": {"name": "validation", "num_bytes": 164561, "num_examples": 547, "dataset_name": "si_nli"}, "test": {"name": "test", "num_bytes": 246518, "num_examples": 998, "dataset_name": "si_nli"}}, "download_checksums": {"https://www.clarin.si/repository/xmlui/bitstream/handle/11356/1707/SI-NLI.zip": {"num_bytes": 410093, "checksum": "e2b3be92049ebb68916a236465940880aeb002d148dce7df94b71e8779080274"}}, "download_size": 410093, "post_processing_size": null, "dataset_size": 1763714, "size_in_bytes": 2173807}}
 
1
+ {"default": {"description": "SI-NLI (Slovene Natural Language Inference Dataset) contains 5,937 human-created Slovene sentence pairs \n(premise and hypothesis) that are manually labeled with the labels \"entailment\", \"contradiction\", and \"neutral\". \nThe dataset was created using sentences that appear in the Slovenian reference corpus ccKres. \nAnnotators were tasked to modify the hypothesis in a candidate pair in a way that reflects one of the labels. \nThe dataset is balanced since the annotators created three modifications (entailment, contradiction, neutral) \nfor each candidate sentence pair.\n", "citation": "@misc{sinli,\n title = {Slovene Natural Language Inference Dataset {SI}-{NLI}},\n author = {Klemen, Matej and {\u000b Z}agar, Ale{\u000b s} and {\u000b C}ibej, Jaka and Robnik-{\u000b S}ikonja, Marko},\n url = {http://hdl.handle.net/11356/1707},\n note = {Slovenian language resource repository {CLARIN}.{SI}},\n year = {2022}\n}\n", "homepage": "http://hdl.handle.net/11356/1707", "license": "Creative Commons - Attribution 4.0 International (CC BY 4.0)", "features": {"pair_id": {"dtype": "string", "id": null, "_type": "Value"}, "premise": {"dtype": "string", "id": null, "_type": "Value"}, "hypothesis": {"dtype": "string", "id": null, "_type": "Value"}, "annotation1": {"dtype": "string", "id": null, "_type": "Value"}, "annotator1_id": {"dtype": "string", "id": null, "_type": "Value"}, "annotation2": {"dtype": "string", "id": null, "_type": "Value"}, "annotator2_id": {"dtype": "string", "id": null, "_type": "Value"}, "annotation3": {"dtype": "string", "id": null, "_type": "Value"}, "annotator3_id": {"dtype": "string", "id": null, "_type": "Value"}, "annotation_final": {"dtype": "string", "id": null, "_type": "Value"}, "label": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "si_nli", "config_name": "default", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 1352635, "num_examples": 4392, "dataset_name": "si_nli"}, "validation": {"name": "validation", "num_bytes": 164561, "num_examples": 547, "dataset_name": "si_nli"}, "test": {"name": "test", "num_bytes": 246518, "num_examples": 998, "dataset_name": "si_nli"}}, "download_checksums": {"https://www.clarin.si/repository/xmlui/bitstream/handle/11356/1707/SI-NLI.zip": {"num_bytes": 410093, "checksum": "e2b3be92049ebb68916a236465940880aeb002d148dce7df94b71e8779080274"}}, "download_size": 410093, "post_processing_size": null, "dataset_size": 1763714, "size_in_bytes": 2173807}, "public": {"description": "SI-NLI (Slovene Natural Language Inference Dataset) contains 5,937 human-created Slovene sentence pairs \n(premise and hypothesis) that are manually labeled with the labels \"entailment\", \"contradiction\", and \"neutral\". \nThe dataset was created using sentences that appear in the Slovenian reference corpus ccKres. \nAnnotators were tasked to modify the hypothesis in a candidate pair in a way that reflects one of the labels. \nThe dataset is balanced since the annotators created three modifications (entailment, contradiction, neutral) \nfor each candidate sentence pair.\n", "citation": "@misc{sinli,\n title = {Slovene Natural Language Inference Dataset {SI}-{NLI}},\n author = {Klemen, Matej and {\u000b Z}agar, Ale{\u000b s} and {\u000b C}ibej, Jaka and Robnik-{\u000b S}ikonja, Marko},\n url = {http://hdl.handle.net/11356/1707},\n note = {Slovenian language resource repository {CLARIN}.{SI}},\n year = {2022}\n}\n", "homepage": "http://hdl.handle.net/11356/1707", "license": "Creative Commons - Attribution 4.0 International (CC BY 4.0)", "features": {"pair_id": {"dtype": "string", "id": null, "_type": "Value"}, "premise": {"dtype": "string", "id": null, "_type": "Value"}, "hypothesis": {"dtype": "string", "id": null, "_type": "Value"}, "annotation1": {"dtype": "string", "id": null, "_type": "Value"}, "annotator1_id": {"dtype": "string", "id": null, "_type": "Value"}, "annotation2": {"dtype": "string", "id": null, "_type": "Value"}, "annotator2_id": {"dtype": "string", "id": null, "_type": "Value"}, "annotation3": {"dtype": "string", "id": null, "_type": "Value"}, "annotator3_id": {"dtype": "string", "id": null, "_type": "Value"}, "annotation_final": {"dtype": "string", "id": null, "_type": "Value"}, "label": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "si_nli", "config_name": "public", "version": {"version_str": "1.0.1", "description": null, "major": 1, "minor": 0, "patch": 1}, "splits": {"train": {"name": "train", "num_bytes": 1352635, "num_examples": 4392, "dataset_name": "si_nli"}, "validation": {"name": "validation", "num_bytes": 164561, "num_examples": 547, "dataset_name": "si_nli"}, "test": {"name": "test", "num_bytes": 246518, "num_examples": 998, "dataset_name": "si_nli"}}, "download_checksums": {"https://www.clarin.si/repository/xmlui/bitstream/handle/11356/1707/SI-NLI.zip": {"num_bytes": 410093, "checksum": "e2b3be92049ebb68916a236465940880aeb002d148dce7df94b71e8779080274"}}, "download_size": 410093, "post_processing_size": null, "dataset_size": 1763714, "size_in_bytes": 2173807}, "private": {"description": "SI-NLI (Slovene Natural Language Inference Dataset) contains 5,937 human-created Slovene sentence pairs \n(premise and hypothesis) that are manually labeled with the labels \"entailment\", \"contradiction\", and \"neutral\". \nThe dataset was created using sentences that appear in the Slovenian reference corpus ccKres. \nAnnotators were tasked to modify the hypothesis in a candidate pair in a way that reflects one of the labels. \nThe dataset is balanced since the annotators created three modifications (entailment, contradiction, neutral) \nfor each candidate sentence pair.\n", "citation": "@misc{sinli,\n title = {Slovene Natural Language Inference Dataset {SI}-{NLI}},\n author = {Klemen, Matej and {\u000b Z}agar, Ale{\u000b s} and {\u000b C}ibej, Jaka and Robnik-{\u000b S}ikonja, Marko},\n url = {http://hdl.handle.net/11356/1707},\n note = {Slovenian language resource repository {CLARIN}.{SI}},\n year = {2022}\n}\n", "homepage": "http://hdl.handle.net/11356/1707", "license": "Creative Commons - Attribution 4.0 International (CC BY 4.0)", "features": {"pair_id": {"dtype": "string", "id": null, "_type": "Value"}, "premise": {"dtype": "string", "id": null, "_type": "Value"}, "hypothesis": {"dtype": "string", "id": null, "_type": "Value"}, "annotation1": {"dtype": "string", "id": null, "_type": "Value"}, "annotator1_id": {"dtype": "string", "id": null, "_type": "Value"}, "annotation2": {"dtype": "string", "id": null, "_type": "Value"}, "annotator2_id": {"dtype": "string", "id": null, "_type": "Value"}, "annotation3": {"dtype": "string", "id": null, "_type": "Value"}, "annotator3_id": {"dtype": "string", "id": null, "_type": "Value"}, "annotation_final": {"dtype": "string", "id": null, "_type": "Value"}, "label": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "si_nli", "config_name": "private", "version": {"version_str": "1.0.1", "description": null, "major": 1, "minor": 0, "patch": 1}, "splits": {}, "download_checksums": {}, "download_size": 0, "post_processing_size": null, "dataset_size": 0, "size_in_bytes": 0}}
si_nli.py CHANGED
@@ -2,7 +2,7 @@
2
 
3
 
4
  import csv
5
- import json
6
  import os
7
 
8
  import datasets
@@ -42,7 +42,16 @@ UNIFIED_LABELS = {"E": "entailment", "N": "neutral", "C": "contradiction"}
42
  class SINLI(datasets.GeneratorBasedBuilder):
43
  """SI-NLI is a Slovene natural language inference dataset."""
44
 
45
- VERSION = datasets.Version("1.0.0")
 
 
 
 
 
 
 
 
 
46
 
47
  def _info(self):
48
  features = datasets.Features({
@@ -68,8 +77,20 @@ class SINLI(datasets.GeneratorBasedBuilder):
68
  )
69
 
70
  def _split_generators(self, dl_manager):
71
- urls = _URLS["si-nli"]
72
- data_dir = dl_manager.download_and_extract(urls)
 
 
 
 
 
 
 
 
 
 
 
 
73
  return [
74
  datasets.SplitGenerator(
75
  name=datasets.Split.TRAIN,
@@ -88,8 +109,7 @@ class SINLI(datasets.GeneratorBasedBuilder):
88
  datasets.SplitGenerator(
89
  name=datasets.Split.TEST,
90
  gen_kwargs={
91
- # Allow the user to load the private test set with this script if they have access to it
92
- "file_path": os.getenv("SI_NLI_TEST_PATH", os.path.join(data_dir, "SI-NLI", "test.tsv")),
93
  "split": "test"
94
  }
95
  )
 
2
 
3
 
4
  import csv
5
+ import logging
6
  import os
7
 
8
  import datasets
 
42
  class SINLI(datasets.GeneratorBasedBuilder):
43
  """SI-NLI is a Slovene natural language inference dataset."""
44
 
45
+ VERSION = datasets.Version("1.0.1")
46
+
47
+ BUILDER_CONFIGS = [
48
+ datasets.BuilderConfig(name="public", version=VERSION,
49
+ description="Load the publicly available dataset (without test labels)."),
50
+ datasets.BuilderConfig(name="private", version=VERSION,
51
+ description="Load the privately available dataset by manuallly providing the path to the data."),
52
+ ]
53
+
54
+ DEFAULT_CONFIG_NAME = "public"
55
 
56
  def _info(self):
57
  features = datasets.Features({
 
77
  )
78
 
79
  def _split_generators(self, dl_manager):
80
+ if self.config.name == "public":
81
+ urls = _URLS["si-nli"]
82
+ data_dir = dl_manager.download_and_extract(urls)
83
+ else:
84
+ # `data_dir` must have the map SI-NLI inside and train.tsv, dev.tsv, test.tsv
85
+ if dl_manager.manual_dir is None or not os.path.exists(dl_manager.manual_dir):
86
+ logging.warning("data_dir does not point to a valid directory")
87
+
88
+ # Allow user to specify path to the private data directory: `load_dataset(..., data_dir=...)`
89
+ data_dir = dl_manager.manual_dir
90
+
91
+ if data_dir is None:
92
+ return []
93
+
94
  return [
95
  datasets.SplitGenerator(
96
  name=datasets.Split.TRAIN,
 
109
  datasets.SplitGenerator(
110
  name=datasets.Split.TEST,
111
  gen_kwargs={
112
+ "file_path": os.path.join(data_dir, "SI-NLI", "test.tsv"),
 
113
  "split": "test"
114
  }
115
  )