Datasets:

Modalities:
Tabular
Text
Formats:
parquet
Languages:
English
Size:
< 1K
ArXiv:
Libraries:
Datasets
pandas
License:
File size: 4,681 Bytes
d8fbf3d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import csv
import json
import os
import pandas as pd
import datasets

_CITATION = """@article{DBLP:journals/corr/abs-2005-11140,
  author    = {Mariona Coll Ardanuy and
               Federico Nanni and
               Kaspar Beelen and
               Kasra Hosseini and
               Ruth Ahnert and
               Jon Lawrence and
               Katherine McDonough and
               Giorgia Tolfo and
               Daniel C. S. Wilson and
               Barbara McGillivray},
  title     = {Living Machines: {A} study of atypical animacy},
  journal   = {CoRR},
  volume    = {abs/2005.11140},
  year      = {2020},
  url       = {https://arxiv.org/abs/2005.11140},
  eprinttype = {arXiv},
  eprint    = {2005.11140},
  timestamp = {Sat, 23 Jan 2021 01:12:25 +0100},
  biburl    = {https://dblp.org/rec/journals/corr/abs-2005-11140.bib},
  bibsource = {dblp computer science bibliography, https://dblp.org}
}
"""


_DESCRIPTION = """\
Atypical animacy detection dataset, based on nineteenth-century sentences in English extracted from an open dataset of nineteenth-century books digitized by the British Library (available via https://doi.org/10.21250/db14, British Library Labs, 2014). 
This dataset contains 598 sentences containing mentions of machines. Each sentence has been annotated according to the animacy and humanness of the machine in the sentence. 
"""

_HOMEPAGE = "https://bl.iro.bl.uk/concern/datasets/323177af-6081-4e93-8aaf-7932ca4a390a?locale=en"

_DATASETNAME = "atypical_animacy"

_LICENSE = "CC0 1.0 Universal Public Domain"

_URLS = {
    _DATASETNAME: "https://bl.iro.bl.uk/downloads/59a8c52f-e0a5-4432-9897-0db8c067627c?locale=en",
}


class AtypicalAnimacy(datasets.GeneratorBasedBuilder):
    """Living Machines: A study of atypical animacy. Each sentence has been annotated according to the animacy and humanness of the target in the sentence. Additionally, the context is also provided"""

    VERSION = datasets.Version("1.1.0")

    def _info(self):
        features = datasets.Features(
            {
                "id": datasets.Value("string"),
                "sentence": datasets.Value("string"),
                "context": datasets.Value("string"),
                "target": datasets.Value("string"),
                "animacy": datasets.Value("float"),
                "humanness": datasets.Value("float"),
                "offsets": [datasets.Value("int32")],
                "date": datasets.Value("string"),
            }
        )
        return datasets.DatasetInfo(
            description=_DESCRIPTION,
            features=features,
            homepage=_HOMEPAGE,
            license=_LICENSE,
            citation=_CITATION,
        )

    def _split_generators(self, dl_manager):
        urls = _URLS[_DATASETNAME]
        data_dir = dl_manager.download_and_extract(urls)
        return [
            datasets.SplitGenerator(
                name=datasets.Split.TRAIN,
                gen_kwargs={
                    "filepath": os.path.join(
                        data_dir, "LwM-nlp-animacy-annotations-machines19thC.tsv"
                    ),
                },
            ),
        ]

    def _generate_examples(self, filepath):
        data = pd.read_csv(filepath, sep="\t", header=0)
        for id, row in data.iterrows():
            date = row.Date
            sentence = row.Sentence.replace("***", "")
            context = row.SentenceCtxt.replace("[SEP]", "").replace("***", "")
            target = row.TargetExpression
            animacy = float(row.animacy)
            humanness = float(row.humanness)
            target_start = sentence.find(target)
            offsets = [target_start, target_start + len(target)]
            id = row.SentenceId
            yield id, {
                "id": id,
                "sentence": sentence,
                "context": context,
                "target": target,
                "animacy": animacy,
                "humanness": humanness,
                "date": date,
                "offsets": offsets,
            }