|
"""TODO(event2Mind): Add a description here.""" |
|
|
|
|
|
import csv |
|
import os |
|
|
|
import datasets |
|
|
|
|
|
|
|
_CITATION = """\ |
|
@inproceedings{event2Mind, |
|
title={Event2Mind: Commonsense Inference on Events, Intents, and Reactions}, |
|
author={Hannah Rashkin and Maarten Sap and Emily Allaway and Noah A. Smith† Yejin Choi}, |
|
year={2018} |
|
} |
|
""" |
|
|
|
|
|
|
|
_DESCRIPTION = """\ |
|
In Event2Mind, we explore the task of understanding stereotypical intents and reactions to events. Through crowdsourcing, we create a large corpus with 25,000 events and free-form descriptions of their intents and reactions, both of the event's subject and (potentially implied) other participants. |
|
""" |
|
_URL = "https://uwnlp.github.io/event2mind/data/event2mind.zip" |
|
|
|
|
|
class Event2mind(datasets.GeneratorBasedBuilder): |
|
"""TODO(event2Mind): Short description of my dataset.""" |
|
|
|
|
|
VERSION = datasets.Version("0.1.0") |
|
|
|
def _info(self): |
|
|
|
return datasets.DatasetInfo( |
|
|
|
description=_DESCRIPTION, |
|
|
|
features=datasets.Features( |
|
{ |
|
|
|
"Source": datasets.Value("string"), |
|
"Event": datasets.Value("string"), |
|
"Xintent": datasets.Value("string"), |
|
"Xemotion": datasets.Value("string"), |
|
"Otheremotion": datasets.Value("string"), |
|
"Xsent": datasets.Value("string"), |
|
"Osent": datasets.Value("string"), |
|
} |
|
), |
|
|
|
|
|
|
|
supervised_keys=None, |
|
|
|
homepage="https://uwnlp.github.io/event2mind/", |
|
citation=_CITATION, |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
"""Returns SplitGenerators.""" |
|
|
|
|
|
|
|
dl_dir = dl_manager.download_and_extract(_URL) |
|
return [ |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TRAIN, |
|
|
|
gen_kwargs={"filepath": os.path.join(dl_dir, "train.csv")}, |
|
), |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TEST, |
|
|
|
gen_kwargs={"filepath": os.path.join(dl_dir, "test.csv")}, |
|
), |
|
datasets.SplitGenerator( |
|
name=datasets.Split.VALIDATION, |
|
|
|
gen_kwargs={"filepath": os.path.join(dl_dir, "dev.csv")}, |
|
), |
|
] |
|
|
|
def _generate_examples(self, filepath): |
|
"""Yields examples.""" |
|
|
|
with open(filepath, encoding="utf-8") as f: |
|
data = csv.DictReader(f) |
|
for id_, row in enumerate(data): |
|
yield id_, { |
|
"Source": row["Source"], |
|
"Event": row["Event"], |
|
"Xintent": row["Xintent"], |
|
"Xemotion": row["Xemotion"], |
|
"Otheremotion": row["Otheremotion"], |
|
"Xsent": row["Xsent"], |
|
"Osent": row["Osent"], |
|
} |
|
|