Datasets:

Modalities:
Text
Formats:
parquet
Sub-tasks:
text-scoring
Languages:
English
ArXiv:
Libraries:
Datasets
pandas
License:
albertvillanova HF staff commited on
Commit
c8b61dc
·
verified ·
1 Parent(s): 7ae0d04

Delete loading script

Browse files
Files changed (1) hide show
  1. has_part.py +0 -117
has_part.py DELETED
@@ -1,117 +0,0 @@
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
- """This dataset is a new knowledge-base (KB) of hasPart relationships, extracted from a large corpus of generic statements. Complementary to other resources available, it is the first which is all three of: accurate (90% precision), salient (covers relationships a person may mention), and has high coverage of common terms (approximated as within a 10 year old’s vocabulary), as well as having several times more hasPart entries than in the popular ontologies ConceptNet and WordNet. In addition, it contains information about quantifiers, argument modifiers, and links the entities to appropriate concepts in Wikipedia and WordNet."""
16
-
17
-
18
- import ast
19
- from collections import defaultdict
20
-
21
- import datasets
22
-
23
-
24
- _CITATION = """\
25
- @misc{bhakthavatsalam2020dogs,
26
- title={Do Dogs have Whiskers? A New Knowledge Base of hasPart Relations},
27
- author={Sumithra Bhakthavatsalam and Kyle Richardson and Niket Tandon and Peter Clark},
28
- year={2020},
29
- eprint={2006.07510},
30
- archivePrefix={arXiv},
31
- primaryClass={cs.CL}
32
- }
33
- """
34
-
35
- _DESCRIPTION = """\
36
- This dataset is a new knowledge-base (KB) of hasPart relationships, extracted from a large corpus of generic statements. Complementary to other resources available, it is the first which is all three of: accurate (90% precision), salient (covers relationships a person may mention), and has high coverage of common terms (approximated as within a 10 year old’s vocabulary), as well as having several times more hasPart entries than in the popular ontologies ConceptNet and WordNet. In addition, it contains information about quantifiers, argument modifiers, and links the entities to appropriate concepts in Wikipedia and WordNet.
37
- """
38
-
39
- _HOMEPAGE = "https://allenai.org/data/haspartkb"
40
-
41
- _LICENSE = ""
42
-
43
-
44
- TSV_ID = "1Ev4RqWcPsLI9rgOGAKh-_dFKqcEZ1u-G"
45
- FOLDER_ID = "1NzjXX46NnpxtgxBrkBWFiUbsXAMdd-lB"
46
- ID = TSV_ID
47
-
48
- _URL = f"https://drive.google.com/uc?export=download&id={ID}"
49
-
50
-
51
- class HasPart(datasets.GeneratorBasedBuilder):
52
- def _info(self):
53
- features = datasets.Features(
54
- {
55
- "arg1": datasets.features.Value("string"),
56
- "arg2": datasets.features.Value("string"),
57
- "score": datasets.features.Value("float64"),
58
- "wikipedia_primary_page": datasets.features.Sequence(datasets.features.Value("string")),
59
- "synset": datasets.features.Sequence(datasets.features.Value("string")),
60
- }
61
- )
62
-
63
- return datasets.DatasetInfo(
64
- description=_DESCRIPTION,
65
- features=features,
66
- supervised_keys=None,
67
- homepage=_HOMEPAGE,
68
- license=_LICENSE,
69
- citation=_CITATION,
70
- )
71
-
72
- def _split_generators(self, dl_manager):
73
- """Returns SplitGenerators."""
74
-
75
- dl_fp = dl_manager.download_and_extract(_URL)
76
-
77
- return [
78
- datasets.SplitGenerator(
79
- name=datasets.Split.TRAIN,
80
- gen_kwargs={
81
- "input_file": dl_fp,
82
- "split": "train",
83
- },
84
- ),
85
- ]
86
-
87
- def _parse_metadata(self, md):
88
- """metadata is a list of dicts in the tsv file, hence needs to be parsed using
89
- ast.literal_eval to convert to python objects.
90
-
91
- Note that metadata resulting in parsing error will be skipped
92
- """
93
- md = ast.literal_eval(md)
94
- dd = defaultdict(list)
95
-
96
- for entry in md:
97
- try:
98
- for k, v in entry.items():
99
- dd[k].append(v)
100
- except AttributeError:
101
- continue
102
- return dd
103
-
104
- def _generate_examples(self, input_file, split):
105
- """Yields examples."""
106
- with open(input_file, encoding="utf-8") as f:
107
- for id_, line in enumerate(f):
108
- _, arg1, arg2, score, metadata = line.split("\t")
109
- metadata = self._parse_metadata(metadata)
110
- example = {
111
- "arg1": arg1,
112
- "arg2": arg2,
113
- "score": float(score),
114
- "wikipedia_primary_page": metadata["wikipedia_primary_page"],
115
- "synset": metadata["synset"],
116
- }
117
- yield id_, example