Christopher Akiki commited on
Commit
fad8874
β€’
1 Parent(s): 0033cd2

Add script

Browse files
datasets.json.gz β†’ 08102021/datasets.json.gz RENAMED
File without changes
evaluation-tables.json.gz β†’ 08102021/evaluation-tables.json.gz RENAMED
File without changes
links-between-papers-and-code.json.gz β†’ 08102021/links-between-papers-and-code.json.gz RENAMED
File without changes
methods.json.gz β†’ 08102021/methods.json.gz RENAMED
File without changes
papers-with-abstracts.json.gz β†’ 08102021/papers-with-abstracts.json.gz RENAMED
File without changes
paperswithcode.py ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ """args.me Dataset"""
16
+
17
+
18
+ import json
19
+
20
+ import datasets
21
+
22
+ _CITATION = """
23
+ TODO ADD PAPERSWITHCODE CITATION
24
+ """
25
+
26
+
27
+ _DESCRIPTION = """\
28
+ The args.me corpus (version 1.0, cleaned) comprises 382 545 arguments crawled from four debate portals in the middle of 2019. The debate portals are Debatewise, IDebate.org, Debatepedia, and Debate.org. The arguments are extracted using heuristics that are designed for each debate portal.
29
+ """
30
+
31
+ _HOMEPAGE = "https://zenodo.org/record/4139439"
32
+
33
+ _LICENSE = "https://creativecommons.org/licenses/by/4.0/legalcode"
34
+
35
+
36
+ _REPO = "https://huggingface.co/datasets/cakiki/paperswithcode/resolve/main"
37
+ _URLs = {
38
+ 'papers': f"{_REPO}/papers-with-abstracts.json.gz",
39
+ 'links': f"{_REPO}/links-between-paper-and-code.json.gz",
40
+ 'evaluation': f"{_REPO}/evaluation-tables.json.gz",
41
+ 'methods': f"{_REPO}/methods.json.gz",
42
+ 'datasets': f"{_REPO}/datasets.json.gz",
43
+
44
+ }
45
+
46
+
47
+ class PapersWithCode(datasets.GeneratorBasedBuilder):
48
+ """382,545 arguments crawled from debate portals"""
49
+
50
+ VERSION = datasets.Version("1.1.0")
51
+ BUILDER_CONFIGS = [
52
+ datasets.BuilderConfig(name="papers", version=VERSION, description="TODO"),
53
+ datasets.BuilderConfig(name="links", version=VERSION, description="TODO"),
54
+ datasets.BuilderConfig(name="evaluation", version=VERSION, description="TODO"),
55
+ datasets.BuilderConfig(name="methods", version=VERSION, description="TODO"),
56
+ datasets.BuilderConfig(name="datasets", version=VERSION, description="TODO")
57
+ ]
58
+
59
+ DEFAULT_CONFIG_NAME = "papers"
60
+
61
+ def _info(self):
62
+ features = datasets.Features(
63
+ {
64
+ "argument": datasets.Value("string"),
65
+ "conclusion": datasets.Value("string"),
66
+ "stance": datasets.Value("string"),
67
+ "id": datasets.Value("string")
68
+ }
69
+ )
70
+ return datasets.DatasetInfo(
71
+ description=_DESCRIPTION,
72
+ features=features,
73
+ supervised_keys=None,
74
+ homepage=_HOMEPAGE,
75
+ license=_LICENSE,
76
+ citation=_CITATION,
77
+ )
78
+
79
+ def _split_generators(self, dl_manager):
80
+ """Returns SplitGenerators."""
81
+ URL = _URLs[self.config.name]
82
+ data_file = dl_manager.download(URL)
83
+ return [
84
+ datasets.SplitGenerator(
85
+ name=datasets.Split.TRAIN,
86
+ gen_kwargs={
87
+ "data_file": data_file,
88
+ },
89
+ ),
90
+ ]
91
+
92
+ def _generate_examples(self, data_file):
93
+ """ Yields examples as (key, example) tuples. """
94
+
95
+
96
+ with open(data_file, encoding="utf-8") as f:
97
+ for row in f:
98
+ data = json.loads(row)
99
+ id_ = data['id']
100
+ content = data["premises"][0]
101
+ yield id_, {
102
+ "argument": content['text'],
103
+ "conclusion": data["conclusion"],
104
+ "stance": content['stance'],
105
+ "id": id_
106
+ }
107
+