mkon commited on
Commit
71017a9
1 Parent(s): 92622e2

final dataloader push

Browse files
ara_stance.py ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2022 Mads Kongsbak and Leon Derczynski
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
+ """A DataLoader for the AraStance dataset."""
15
+
16
+ import csv
17
+ import json
18
+ import os
19
+
20
+ import datasets
21
+
22
+ _CITATION = """\
23
+ @article{arastance,
24
+ url = {https://arxiv.org/abs/2104.13559},
25
+ author = {Alhindi, Tariq and Alabdulkarim, Amal and Alshehri, Ali and Abdul-Mageed, Muhammad and Nakov, Preslav},
26
+ title = {AraStance: A Multi-Country and Multi-Domain Dataset of Arabic Stance Detection for Fact Checking},
27
+ year = {2021},
28
+ copyright = {Creative Commons Attribution 4.0 International}
29
+ }
30
+
31
+ """
32
+
33
+ _DESCRIPTION = """\
34
+ The AraStance dataset contains true and false claims, where each claim is paired with one or more documents. Each claim–article pair has a stance label: agree, disagree, discuss, or unrelated.
35
+ """
36
+
37
+ _HOMEPAGE = "https://github.com/Tariq60/arastance"
38
+
39
+ _LICENSE = "cc-by-4.0"
40
+
41
+ class ARAStanceConfig(datasets.BuilderConfig):
42
+
43
+ def __init__(self, **kwargs):
44
+ super(ARAStanceConfig, self).__init__(**kwargs)
45
+
46
+ class ARAStance(datasets.GeneratorBasedBuilder):
47
+ """The AraStance dataset made in triples of (claim, article, stance)"""
48
+
49
+ VERSION = datasets.Version("1.0.0")
50
+
51
+ BUILDER_CONFIGS = [
52
+ ARAStanceConfig(name="stance", version=VERSION, description=""),
53
+ ]
54
+
55
+ def _info(self):
56
+ features = datasets.Features(
57
+ {
58
+ "id": datasets.Value("string"),
59
+ "claim": datasets.Value("string"),
60
+ "article": datasets.Value("string"),
61
+ "stance": datasets.features.ClassLabel(
62
+ names=[
63
+ "Agree",
64
+ "Disagree",
65
+ "Discuss",
66
+ "Unrelated",
67
+ ]
68
+ )
69
+ }
70
+ )
71
+
72
+ return datasets.DatasetInfo(
73
+ description=_DESCRIPTION,
74
+ features=features,
75
+ homepage=_HOMEPAGE,
76
+ license=_LICENSE,
77
+ citation=_CITATION,
78
+ )
79
+
80
+ def _split_generators(self, dl_manager):
81
+ train_text = dl_manager.download_and_extract("arastance_train.csv")
82
+ valid_text = dl_manager.download_and_extract("arastance_valid.csv")
83
+ test_text = dl_manager.download_and_extract("arastance_test.csv")
84
+
85
+ return [
86
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": train_text, "split": "train"}),
87
+ datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": valid_text, "split": "validation"}),
88
+ datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": test_text, "split": "test"}),
89
+ ]
90
+
91
+ def _generate_examples(self, filepath, split):
92
+ with open(filepath, encoding="utf-8") as f:
93
+ reader = csv.DictReader(f, delimiter=",")
94
+ guid = 0
95
+ for instance in reader:
96
+ instance["claim"] = instance.pop("claim")
97
+ instance["article"] = instance.pop("article")
98
+ instance["stance"] = instance.pop("stance")
99
+ instance['id'] = str(guid)
100
+ yield guid, instance
101
+ guid += 1
arastance-test.csv → arastance_test.csv RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:e00271ec6f06af166bb30abf1df4800d218231ea6b0723032454b0c9f3f958d2
3
- size 5401472
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1f22ba28e9bb302ba8d4a61af764ee126a6c60fa77896f87bb5e590c9f11f240
3
+ size 5401474
arastance-train.csv → arastance_train.csv RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:5d15cce0a7ae20a4aab15b45542ed63e88cc7d5b99c57a2727a22bbd433b4830
3
- size 28782509
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6517c57b701d0df9d2800b8d275ac5fcedac323798c1632322062649670c582b
3
+ size 28782511
arastance-valid.csv → arastance_valid.csv RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:ea090d6af8030f1d25d99396a0e7c3ec82ea06ffdf29e6018f2232a97c97fa33
3
- size 6899118
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e4cd1b2c7ee96e3ed87810949e28d63186321075a5e7c0eff3254ab171865f67
3
+ size 6899120
dataset_infos.json ADDED
@@ -0,0 +1 @@
 
1
+ {"stance": {"description": "The AraStance dataset contains true and false claims, where each claim is paired with one or more documents. Each claim\u2013article pair has a stance label: agree, disagree, discuss, or unrelated.\n", "citation": "@article{arastance,\n url = {https://arxiv.org/abs/2104.13559},\n author = {Alhindi, Tariq and Alabdulkarim, Amal and Alshehri, Ali and Abdul-Mageed, Muhammad and Nakov, Preslav},\n title = {AraStance: A Multi-Country and Multi-Domain Dataset of Arabic Stance Detection for Fact Checking},\n year = {2021}, \n copyright = {Creative Commons Attribution 4.0 International}\n}\n\n", "homepage": "https://github.com/Tariq60/arastance", "license": "cc-by-4.0", "features": {"id": {"dtype": "string", "id": null, "_type": "Value"}, "claim": {"dtype": "string", "id": null, "_type": "Value"}, "article": {"dtype": "string", "id": null, "_type": "Value"}, "stance": {"num_classes": 4, "names": ["Agree", "Disagree", "Discuss", "Unrelated"], "id": null, "_type": "ClassLabel"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "ara_stance", "config_name": "stance", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 28770728, "num_examples": 2848, "dataset_name": "ara_stance"}, "validation": {"name": "validation", "num_bytes": 6895664, "num_examples": 569, "dataset_name": "ara_stance"}, "test": {"name": "test", "num_bytes": 5400545, "num_examples": 646, "dataset_name": "ara_stance"}}, "download_checksums": {"arastance_train.csv": {"num_bytes": 28782511, "checksum": "6517c57b701d0df9d2800b8d275ac5fcedac323798c1632322062649670c582b"}, "arastance_valid.csv": {"num_bytes": 6899120, "checksum": "e4cd1b2c7ee96e3ed87810949e28d63186321075a5e7c0eff3254ab171865f67"}, "arastance_test.csv": {"num_bytes": 5401474, "checksum": "1f22ba28e9bb302ba8d4a61af764ee126a6c60fa77896f87bb5e590c9f11f240"}}, "download_size": 41083105, "post_processing_size": null, "dataset_size": 41066937, "size_in_bytes": 82150042}}