Datasets:

Modalities:
Text
Sub-tasks:
fact-checking
Languages:
English
ArXiv:
Libraries:
Datasets
License:
mkon commited on
Commit
2c055fc
1 Parent(s): 676847f

more split stuff

Browse files
Files changed (2) hide show
  1. rumoureval2019_val.csv +0 -0
  2. rumoureval_2019.py +26 -64
rumoureval2019_val.csv ADDED
The diff for this file is too large to render. See raw diff
 
rumoureval_2019.py CHANGED
@@ -45,95 +45,57 @@ _HOMEPAGE = ""
45
  # TODO: Add the licence for the dataset here if you can find it
46
  _LICENSE = ""
47
 
48
- # TODO: Add link to the official dataset URLs here
49
- # The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
50
- # This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
51
- _URLS = {
52
- "train": "rumoureval2019_train.csv",
53
- "validation": "NA",
54
- }
55
-
56
-
57
- # TODO: Name of the dataset usually match the script name with CamelCase instead of snake_case
58
  class RumourEval2019(datasets.GeneratorBasedBuilder):
59
  """TODO: Short description of my dataset."""
60
 
61
- VERSION = datasets.Version("1.1.0")
62
-
63
- # This is an example of a dataset with multiple configurations.
64
- # If you don't want/need to define several sub-sets in your dataset,
65
- # just remove the BUILDER_CONFIG_CLASS and the BUILDER_CONFIGS attributes.
66
-
67
- # If you need to make complex sub-parts in the datasets with configurable options
68
- # You can create your own builder configuration class to store attribute, inheriting from datasets.BuilderConfig
69
- # BUILDER_CONFIG_CLASS = MyBuilderConfig
70
 
71
- # You will be able to load one or the other configurations in the following list with
72
- # data = datasets.load_dataset('my_dataset', 'first_domain')
73
- # data = datasets.load_dataset('my_dataset', 'second_domain')
74
  BUILDER_CONFIGS = [
75
- datasets.BuilderConfig(name="train", version=VERSION, description="Training"),
76
- datasets.BuilderConfig(name="validation", version=VERSION, description="Validation")
 
77
  ]
78
-
79
- DEFAULT_CONFIG_NAME = "train" # It's not mandatory to have a default configuration. Just use one if it make sense.
80
-
81
  def _info(self):
82
- # TODO: This method specifies the datasets.DatasetInfo object which contains informations and typings for the dataset
83
- if self.config.name == "train": # This is the name of the configuration selected in BUILDER_CONFIGS above
84
- features = datasets.Features(
85
- {
86
- "id": datasets.Value("string"),
87
- "source_text": datasets.Value("string"),
88
- "reply_text": datasets.Value("string"),
89
- "label": datasets.features.ClassLabel(
90
- names=[
91
- "support",
92
- "query",
93
- "deny",
94
- "comment"
95
- ]
96
- )
97
- # These are the features of your dataset like images, labels ...
98
- }
99
- )
100
 
101
  return datasets.DatasetInfo(
102
- # This is the description that will appear on the datasets page.
103
  description=_DESCRIPTION,
104
- # This defines the different columns of the dataset and their types
105
- features=features, # Here we define them above because they are different between the two configurations
106
- # If there's a common (input, target) tuple from the features, uncomment supervised_keys line below and
107
- # specify them. They'll be used if as_supervised=True in builder.as_dataset.
108
- # supervised_keys=("sentence", "label"),
109
- # Homepage of the dataset for documentation
110
  homepage=_HOMEPAGE,
111
- # License for the dataset if available
112
  license=_LICENSE,
113
- # Citation for the dataset
114
  citation=_CITATION,
115
  )
116
 
117
  def _split_generators(self, dl_manager):
118
- # TODO: This method is tasked with downloading/extracting the data and defining the splits depending on the configuration
119
- # If several configurations are possible (listed in BUILDER_CONFIGS), the configuration selected by the user is in self.config.name
120
-
121
- # dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
122
- # It can accept any type or nested list/dict and will give back the same structure with the url replaced with path to local files.
123
- # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
124
- urls = _URLS[self.config.name]
125
  train_text = dl_manager.download_and_extract("rumoureval2019_train.csv")
 
126
  return [
127
- datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": train_text, "split": "train"})
 
128
  ]
129
 
130
  # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
131
  def _generate_examples(self, filepath, split):
132
  # TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
133
  # The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
134
- if split == "train":
135
  with open(filepath, encoding="utf-8") as f:
136
- reader = csv.DictReader(f, delimiter=",", quotechar='"')
137
  guid = 0
138
  for instance in reader:
139
  instance["source_text"] = instance.pop("source_text")
 
45
  # TODO: Add the licence for the dataset here if you can find it
46
  _LICENSE = ""
47
 
 
 
 
 
 
 
 
 
 
 
48
  class RumourEval2019(datasets.GeneratorBasedBuilder):
49
  """TODO: Short description of my dataset."""
50
 
51
+ VERSION = datasets.Version("0.9.0")
 
 
 
 
 
 
 
 
52
 
 
 
 
53
  BUILDER_CONFIGS = [
54
+ datasets.BuilderConfig(name="train", version=VERSION, description="Training data for RumourEval 2019"),
55
+ datasets.BuilderConfig(name="validation", version=VERSION, description="Validation data for RumourEval 2019"),
56
+ datasets.BuilderConfig(name="test", version=VERSION, description="Testing data for RumourEval 2019")
57
  ]
58
+
 
 
59
  def _info(self):
60
+ features = datasets.Features(
61
+ {
62
+ "id": datasets.Value("string"),
63
+ "source_text": datasets.Value("string"),
64
+ "reply_text": datasets.Value("string"),
65
+ "label": datasets.features.ClassLabel(
66
+ names=[
67
+ "support",
68
+ "query",
69
+ "deny",
70
+ "comment"
71
+ ]
72
+ )
73
+ }
74
+ )
 
 
 
75
 
76
  return datasets.DatasetInfo(
 
77
  description=_DESCRIPTION,
78
+ features=features,
 
 
 
 
 
79
  homepage=_HOMEPAGE,
 
80
  license=_LICENSE,
 
81
  citation=_CITATION,
82
  )
83
 
84
  def _split_generators(self, dl_manager):
 
 
 
 
 
 
 
85
  train_text = dl_manager.download_and_extract("rumoureval2019_train.csv")
86
+ validation_text = dl_manager.download_and_extract("rumoureval2019_val.csv")
87
  return [
88
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": train_text, "split": "train"}),
89
+ datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": validation_text, "split": "validation"})
90
  ]
91
 
92
  # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
93
  def _generate_examples(self, filepath, split):
94
  # TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
95
  # The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
96
+ if split == "train" or split == "validation":
97
  with open(filepath, encoding="utf-8") as f:
98
+ reader = csv.DictReader(f, delimiter=",")
99
  guid = 0
100
  for instance in reader:
101
  instance["source_text"] = instance.pop("source_text")