|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""TODO: Add a description here.""" |
|
|
|
|
|
import csv |
|
import json |
|
import os |
|
|
|
import datasets |
|
|
|
|
|
|
|
|
|
_CITATION = """\ |
|
@inproceedings{thomson-etal-2020-sportsett, |
|
title = "{S}port{S}ett:Basketball - A robust and maintainable data-set for Natural Language Generation", |
|
author = "Thomson, Craig and |
|
Reiter, Ehud and |
|
Sripada, Somayajulu", |
|
booktitle = "Proceedings of the Workshop on Intelligent Information Processing and Natural Language Generation", |
|
month = sep, |
|
year = "2020", |
|
address = "Santiago de Compostela, Spain", |
|
publisher = "Association for Computational Lingustics", |
|
url = "https://aclanthology.org/2020.intellang-1.4", |
|
pages = "32--40", |
|
} |
|
""" |
|
|
|
|
|
|
|
_DESCRIPTION = """\ |
|
SportSett:Basketball dataset for Data-to-Text Generation contains NBA games stats aligned with their human written summaries. |
|
""" |
|
|
|
|
|
_HOMEPAGE = "https://github.com/nlgcat/sport_sett_basketball" |
|
|
|
|
|
_LICENSE = "" |
|
|
|
|
|
|
|
|
|
_URLs = { |
|
"train": "train.jsonl", |
|
"validation": "validation.jsonl", |
|
"test": "test.jsonl" |
|
} |
|
|
|
|
|
|
|
class SportSettBasketball(datasets.GeneratorBasedBuilder): |
|
"""SportSett:Basketball datatset for Data-to-Text Generation.""" |
|
|
|
VERSION = datasets.Version("1.1.0") |
|
|
|
def _info(self): |
|
features = datasets.Features( |
|
{ |
|
"sportsett_id": datasets.Value("string"), |
|
"gem_id": datasets.Value("string"), |
|
"game": { |
|
"day": datasets.Value("string"), |
|
"month": datasets.Value("string"), |
|
"year": datasets.Value("string"), |
|
"dayname": datasets.Value("string"), |
|
"season": datasets.Value("string"), |
|
"stadium": datasets.Value("string"), |
|
"city": datasets.Value("string"), |
|
"state": datasets.Value("string"), |
|
"attendance": datasets.Value("string"), |
|
"capacity": datasets.Value("string"), |
|
"game_id": datasets.Value("string") |
|
}, |
|
"teams": { |
|
"home": { |
|
"name": datasets.Value("string"), |
|
"place": datasets.Value("string"), |
|
"conference": datasets.Value("string"), |
|
"division": datasets.Value("string"), |
|
"wins": datasets.Value("string"), |
|
"losses": datasets.Value("string"), |
|
"conference_standing": datasets.Value("int32"), |
|
"game_number": datasets.Value("string"), |
|
"previous_game_id": datasets.Value("string"), |
|
"next_game_id": datasets.Value("string"), |
|
"line_score": { |
|
"game": { |
|
"FG3A": datasets.Value("string"), |
|
"FG3M": datasets.Value("string"), |
|
"FG3_PCT": datasets.Value("string"), |
|
"FGA": datasets.Value("string"), |
|
"FGM": datasets.Value("string"), |
|
"FG_PCT": datasets.Value("string"), |
|
"FTA": datasets.Value("string"), |
|
"FTM": datasets.Value("string"), |
|
"FT_PCT": datasets.Value("string"), |
|
"DREB": datasets.Value("string"), |
|
"OREB": datasets.Value("string"), |
|
"TREB": datasets.Value("string"), |
|
"BLK": datasets.Value("string"), |
|
"AST": datasets.Value("string"), |
|
"STL": datasets.Value("string"), |
|
"TOV": datasets.Value("string"), |
|
"PF": datasets.Value("string"), |
|
"PTS": datasets.Value("string"), |
|
"MIN": datasets.Value("string") |
|
}, |
|
"H1": { |
|
"FG3A": datasets.Value("string"), |
|
"FG3M": datasets.Value("string"), |
|
"FG3_PCT": datasets.Value("string"), |
|
"FGA": datasets.Value("string"), |
|
"FGM": datasets.Value("string"), |
|
"FG_PCT": datasets.Value("string"), |
|
"FTA": datasets.Value("string"), |
|
"FTM": datasets.Value("string"), |
|
"FT_PCT": datasets.Value("string"), |
|
"DREB": datasets.Value("string"), |
|
"OREB": datasets.Value("string"), |
|
"TREB": datasets.Value("string"), |
|
"BLK": datasets.Value("string"), |
|
"AST": datasets.Value("string"), |
|
"STL": datasets.Value("string"), |
|
"TOV": datasets.Value("string"), |
|
"PTS": datasets.Value("string"), |
|
"MIN": datasets.Value("string") |
|
}, |
|
"H2": { |
|
"FG3A": datasets.Value("string"), |
|
"FG3M": datasets.Value("string"), |
|
"FG3_PCT": datasets.Value("string"), |
|
"FGA": datasets.Value("string"), |
|
"FGM": datasets.Value("string"), |
|
"FG_PCT": datasets.Value("string"), |
|
"FTA": datasets.Value("string"), |
|
"FTM": datasets.Value("string"), |
|
"FT_PCT": datasets.Value("string"), |
|
"DREB": datasets.Value("string"), |
|
"OREB": datasets.Value("string"), |
|
"TREB": datasets.Value("string"), |
|
"BLK": datasets.Value("string"), |
|
"AST": datasets.Value("string"), |
|
"STL": datasets.Value("string"), |
|
"TOV": datasets.Value("string"), |
|
"PTS": datasets.Value("string"), |
|
"MIN": datasets.Value("string") |
|
}, |
|
"Q1": { |
|
"FG3A": datasets.Value("string"), |
|
"FG3M": datasets.Value("string"), |
|
"FG3_PCT": datasets.Value("string"), |
|
"FGA": datasets.Value("string"), |
|
"FGM": datasets.Value("string"), |
|
"FG_PCT": datasets.Value("string"), |
|
"FTA": datasets.Value("string"), |
|
"FTM": datasets.Value("string"), |
|
"FT_PCT": datasets.Value("string"), |
|
"DREB": datasets.Value("string"), |
|
"OREB": datasets.Value("string"), |
|
"TREB": datasets.Value("string"), |
|
"BLK": datasets.Value("string"), |
|
"AST": datasets.Value("string"), |
|
"STL": datasets.Value("string"), |
|
"TOV": datasets.Value("string"), |
|
"PTS": datasets.Value("string"), |
|
"MIN": datasets.Value("string") |
|
}, |
|
"Q2": { |
|
"FG3A": datasets.Value("string"), |
|
"FG3M": datasets.Value("string"), |
|
"FG3_PCT": datasets.Value("string"), |
|
"FGA": datasets.Value("string"), |
|
"FGM": datasets.Value("string"), |
|
"FG_PCT": datasets.Value("string"), |
|
"FTA": datasets.Value("string"), |
|
"FTM": datasets.Value("string"), |
|
"FT_PCT": datasets.Value("string"), |
|
"DREB": datasets.Value("string"), |
|
"OREB": datasets.Value("string"), |
|
"TREB": datasets.Value("string"), |
|
"BLK": datasets.Value("string"), |
|
"AST": datasets.Value("string"), |
|
"STL": datasets.Value("string"), |
|
"TOV": datasets.Value("string"), |
|
"PTS": datasets.Value("string"), |
|
"MIN": datasets.Value("string") |
|
}, |
|
"Q3": { |
|
"FG3A": datasets.Value("string"), |
|
"FG3M": datasets.Value("string"), |
|
"FG3_PCT": datasets.Value("string"), |
|
"FGA": datasets.Value("string"), |
|
"FGM": datasets.Value("string"), |
|
"FG_PCT": datasets.Value("string"), |
|
"FTA": datasets.Value("string"), |
|
"FTM": datasets.Value("string"), |
|
"FT_PCT": datasets.Value("string"), |
|
"DREB": datasets.Value("string"), |
|
"OREB": datasets.Value("string"), |
|
"TREB": datasets.Value("string"), |
|
"BLK": datasets.Value("string"), |
|
"AST": datasets.Value("string"), |
|
"STL": datasets.Value("string"), |
|
"TOV": datasets.Value("string"), |
|
"PTS": datasets.Value("string"), |
|
"MIN": datasets.Value("string") |
|
}, |
|
"Q4": { |
|
"FG3A": datasets.Value("string"), |
|
"FG3M": datasets.Value("string"), |
|
"FG3_PCT": datasets.Value("string"), |
|
"FGA": datasets.Value("string"), |
|
"FGM": datasets.Value("string"), |
|
"FG_PCT": datasets.Value("string"), |
|
"FTA": datasets.Value("string"), |
|
"FTM": datasets.Value("string"), |
|
"FT_PCT": datasets.Value("string"), |
|
"DREB": datasets.Value("string"), |
|
"OREB": datasets.Value("string"), |
|
"TREB": datasets.Value("string"), |
|
"BLK": datasets.Value("string"), |
|
"AST": datasets.Value("string"), |
|
"STL": datasets.Value("string"), |
|
"TOV": datasets.Value("string"), |
|
"PTS": datasets.Value("string"), |
|
"MIN": datasets.Value("string") |
|
}, |
|
"OT": { |
|
"FG3A": datasets.Value("string"), |
|
"FG3M": datasets.Value("string"), |
|
"FG3_PCT": datasets.Value("string"), |
|
"FGA": datasets.Value("string"), |
|
"FGM": datasets.Value("string"), |
|
"FG_PCT": datasets.Value("string"), |
|
"FTA": datasets.Value("string"), |
|
"FTM": datasets.Value("string"), |
|
"FT_PCT": datasets.Value("string"), |
|
"DREB": datasets.Value("string"), |
|
"OREB": datasets.Value("string"), |
|
"TREB": datasets.Value("string"), |
|
"BLK": datasets.Value("string"), |
|
"AST": datasets.Value("string"), |
|
"STL": datasets.Value("string"), |
|
"TOV": datasets.Value("string"), |
|
"PTS": datasets.Value("string"), |
|
"MIN": datasets.Value("string") |
|
} |
|
}, |
|
"box_score": [ |
|
{ |
|
"first_name": datasets.Value("string"), |
|
"last_name": datasets.Value("string"), |
|
"name": datasets.Value("string"), |
|
"starter": datasets.Value("string"), |
|
"MIN": datasets.Value("string"), |
|
"FGM": datasets.Value("string"), |
|
"FGA": datasets.Value("string"), |
|
"FG_PCT": datasets.Value("string"), |
|
"FG3M": datasets.Value("string"), |
|
"FG3A": datasets.Value("string"), |
|
"FG3_PCT": datasets.Value("string"), |
|
"FTM": datasets.Value("string"), |
|
"FTA": datasets.Value("string"), |
|
"FT_PCT": datasets.Value("string"), |
|
"OREB": datasets.Value("string"), |
|
"DREB": datasets.Value("string"), |
|
"TREB": datasets.Value("string"), |
|
"AST": datasets.Value("string"), |
|
"STL": datasets.Value("string"), |
|
"BLK": datasets.Value("string"), |
|
"TOV": datasets.Value("string"), |
|
"PF": datasets.Value("string"), |
|
"PTS": datasets.Value("string"), |
|
"+/-": datasets.Value("string"), |
|
"DOUBLE": datasets.Value("string") |
|
} |
|
], |
|
"next_game": { |
|
"day": datasets.Value("string"), |
|
"month": datasets.Value("string"), |
|
"year": datasets.Value("string"), |
|
"dayname": datasets.Value("string"), |
|
"stadium": datasets.Value("string"), |
|
"city": datasets.Value("string"), |
|
"opponent_name": datasets.Value("string"), |
|
"opponent_place": datasets.Value("string"), |
|
"is_home": datasets.Value("string"), |
|
} |
|
}, |
|
"vis": { |
|
"name": datasets.Value("string"), |
|
"place": datasets.Value("string"), |
|
"conference": datasets.Value("string"), |
|
"division": datasets.Value("string"), |
|
"wins": datasets.Value("string"), |
|
"losses": datasets.Value("string"), |
|
"conference_standing": datasets.Value("int32"), |
|
"game_number": datasets.Value("string"), |
|
"previous_game_id": datasets.Value("string"), |
|
"next_game_id": datasets.Value("string"), |
|
"line_score": { |
|
"game": { |
|
"FG3A": datasets.Value("string"), |
|
"FG3M": datasets.Value("string"), |
|
"FG3_PCT": datasets.Value("string"), |
|
"FGA": datasets.Value("string"), |
|
"FGM": datasets.Value("string"), |
|
"FG_PCT": datasets.Value("string"), |
|
"FTA": datasets.Value("string"), |
|
"FTM": datasets.Value("string"), |
|
"FT_PCT": datasets.Value("string"), |
|
"DREB": datasets.Value("string"), |
|
"OREB": datasets.Value("string"), |
|
"TREB": datasets.Value("string"), |
|
"BLK": datasets.Value("string"), |
|
"AST": datasets.Value("string"), |
|
"STL": datasets.Value("string"), |
|
"TOV": datasets.Value("string"), |
|
"PF": datasets.Value("string"), |
|
"PTS": datasets.Value("string"), |
|
"MIN": datasets.Value("string") |
|
}, |
|
"H1": { |
|
"FG3A": datasets.Value("string"), |
|
"FG3M": datasets.Value("string"), |
|
"FG3_PCT": datasets.Value("string"), |
|
"FGA": datasets.Value("string"), |
|
"FGM": datasets.Value("string"), |
|
"FG_PCT": datasets.Value("string"), |
|
"FTA": datasets.Value("string"), |
|
"FTM": datasets.Value("string"), |
|
"FT_PCT": datasets.Value("string"), |
|
"DREB": datasets.Value("string"), |
|
"OREB": datasets.Value("string"), |
|
"TREB": datasets.Value("string"), |
|
"BLK": datasets.Value("string"), |
|
"AST": datasets.Value("string"), |
|
"STL": datasets.Value("string"), |
|
"TOV": datasets.Value("string"), |
|
"PTS": datasets.Value("string"), |
|
"MIN": datasets.Value("string") |
|
}, |
|
"H2": { |
|
"FG3A": datasets.Value("string"), |
|
"FG3M": datasets.Value("string"), |
|
"FG3_PCT": datasets.Value("string"), |
|
"FGA": datasets.Value("string"), |
|
"FGM": datasets.Value("string"), |
|
"FG_PCT": datasets.Value("string"), |
|
"FTA": datasets.Value("string"), |
|
"FTM": datasets.Value("string"), |
|
"FT_PCT": datasets.Value("string"), |
|
"DREB": datasets.Value("string"), |
|
"OREB": datasets.Value("string"), |
|
"TREB": datasets.Value("string"), |
|
"BLK": datasets.Value("string"), |
|
"AST": datasets.Value("string"), |
|
"STL": datasets.Value("string"), |
|
"TOV": datasets.Value("string"), |
|
"PTS": datasets.Value("string"), |
|
"MIN": datasets.Value("string") |
|
}, |
|
"Q1": { |
|
"FG3A": datasets.Value("string"), |
|
"FG3M": datasets.Value("string"), |
|
"FG3_PCT": datasets.Value("string"), |
|
"FGA": datasets.Value("string"), |
|
"FGM": datasets.Value("string"), |
|
"FG_PCT": datasets.Value("string"), |
|
"FTA": datasets.Value("string"), |
|
"FTM": datasets.Value("string"), |
|
"FT_PCT": datasets.Value("string"), |
|
"DREB": datasets.Value("string"), |
|
"OREB": datasets.Value("string"), |
|
"TREB": datasets.Value("string"), |
|
"BLK": datasets.Value("string"), |
|
"AST": datasets.Value("string"), |
|
"STL": datasets.Value("string"), |
|
"TOV": datasets.Value("string"), |
|
"PTS": datasets.Value("string"), |
|
"MIN": datasets.Value("string") |
|
}, |
|
"Q2": { |
|
"FG3A": datasets.Value("string"), |
|
"FG3M": datasets.Value("string"), |
|
"FG3_PCT": datasets.Value("string"), |
|
"FGA": datasets.Value("string"), |
|
"FGM": datasets.Value("string"), |
|
"FG_PCT": datasets.Value("string"), |
|
"FTA": datasets.Value("string"), |
|
"FTM": datasets.Value("string"), |
|
"FT_PCT": datasets.Value("string"), |
|
"DREB": datasets.Value("string"), |
|
"OREB": datasets.Value("string"), |
|
"TREB": datasets.Value("string"), |
|
"BLK": datasets.Value("string"), |
|
"AST": datasets.Value("string"), |
|
"STL": datasets.Value("string"), |
|
"TOV": datasets.Value("string"), |
|
"PTS": datasets.Value("string"), |
|
"MIN": datasets.Value("string") |
|
}, |
|
"Q3": { |
|
"FG3A": datasets.Value("string"), |
|
"FG3M": datasets.Value("string"), |
|
"FG3_PCT": datasets.Value("string"), |
|
"FGA": datasets.Value("string"), |
|
"FGM": datasets.Value("string"), |
|
"FG_PCT": datasets.Value("string"), |
|
"FTA": datasets.Value("string"), |
|
"FTM": datasets.Value("string"), |
|
"FT_PCT": datasets.Value("string"), |
|
"DREB": datasets.Value("string"), |
|
"OREB": datasets.Value("string"), |
|
"TREB": datasets.Value("string"), |
|
"BLK": datasets.Value("string"), |
|
"AST": datasets.Value("string"), |
|
"STL": datasets.Value("string"), |
|
"TOV": datasets.Value("string"), |
|
"PTS": datasets.Value("string"), |
|
"MIN": datasets.Value("string") |
|
}, |
|
"Q4": { |
|
"FG3A": datasets.Value("string"), |
|
"FG3M": datasets.Value("string"), |
|
"FG3_PCT": datasets.Value("string"), |
|
"FGA": datasets.Value("string"), |
|
"FGM": datasets.Value("string"), |
|
"FG_PCT": datasets.Value("string"), |
|
"FTA": datasets.Value("string"), |
|
"FTM": datasets.Value("string"), |
|
"FT_PCT": datasets.Value("string"), |
|
"DREB": datasets.Value("string"), |
|
"OREB": datasets.Value("string"), |
|
"TREB": datasets.Value("string"), |
|
"BLK": datasets.Value("string"), |
|
"AST": datasets.Value("string"), |
|
"STL": datasets.Value("string"), |
|
"TOV": datasets.Value("string"), |
|
"PTS": datasets.Value("string"), |
|
"MIN": datasets.Value("string") |
|
}, |
|
"OT": { |
|
"FG3A": datasets.Value("string"), |
|
"FG3M": datasets.Value("string"), |
|
"FG3_PCT": datasets.Value("string"), |
|
"FGA": datasets.Value("string"), |
|
"FGM": datasets.Value("string"), |
|
"FG_PCT": datasets.Value("string"), |
|
"FTA": datasets.Value("string"), |
|
"FTM": datasets.Value("string"), |
|
"FT_PCT": datasets.Value("string"), |
|
"DREB": datasets.Value("string"), |
|
"OREB": datasets.Value("string"), |
|
"TREB": datasets.Value("string"), |
|
"BLK": datasets.Value("string"), |
|
"AST": datasets.Value("string"), |
|
"STL": datasets.Value("string"), |
|
"TOV": datasets.Value("string"), |
|
"PTS": datasets.Value("string"), |
|
"MIN": datasets.Value("string") |
|
} |
|
}, |
|
"box_score": [ |
|
{ |
|
"first_name": datasets.Value("string"), |
|
"last_name": datasets.Value("string"), |
|
"name": datasets.Value("string"), |
|
"starter": datasets.Value("string"), |
|
"MIN": datasets.Value("string"), |
|
"FGM": datasets.Value("string"), |
|
"FGA": datasets.Value("string"), |
|
"FG_PCT": datasets.Value("string"), |
|
"FG3M": datasets.Value("string"), |
|
"FG3A": datasets.Value("string"), |
|
"FG3_PCT": datasets.Value("string"), |
|
"FTM": datasets.Value("string"), |
|
"FTA": datasets.Value("string"), |
|
"FT_PCT": datasets.Value("string"), |
|
"OREB": datasets.Value("string"), |
|
"DREB": datasets.Value("string"), |
|
"TREB": datasets.Value("string"), |
|
"AST": datasets.Value("string"), |
|
"STL": datasets.Value("string"), |
|
"BLK": datasets.Value("string"), |
|
"TOV": datasets.Value("string"), |
|
"PF": datasets.Value("string"), |
|
"PTS": datasets.Value("string"), |
|
"+/-": datasets.Value("string"), |
|
"DOUBLE": datasets.Value("string") |
|
} |
|
], |
|
"next_game": { |
|
"day": datasets.Value("string"), |
|
"month": datasets.Value("string"), |
|
"year": datasets.Value("string"), |
|
"dayname": datasets.Value("string"), |
|
"stadium": datasets.Value("string"), |
|
"city": datasets.Value("string"), |
|
"opponent_name": datasets.Value("string"), |
|
"opponent_place": datasets.Value("string"), |
|
"is_home": datasets.Value("string"), |
|
} |
|
} |
|
}, |
|
"summaries": datasets.Sequence(datasets.Value("string")), |
|
} |
|
) |
|
return datasets.DatasetInfo( |
|
description=_DESCRIPTION, |
|
features=features, |
|
supervised_keys=None, |
|
homepage=_HOMEPAGE, |
|
license=_LICENSE, |
|
citation=_CITATION, |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
"""Returns SplitGenerators.""" |
|
|
|
|
|
|
|
|
|
|
|
|
|
data_dir = dl_manager.download_and_extract(_URLs) |
|
return [ |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TRAIN, |
|
|
|
gen_kwargs={ |
|
"filepath": data_dir["train"], |
|
"split": "train", |
|
}, |
|
), |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TEST, |
|
|
|
gen_kwargs={ |
|
"filepath": data_dir["test"], |
|
"split": "test" |
|
}, |
|
), |
|
datasets.SplitGenerator( |
|
name=datasets.Split.VALIDATION, |
|
|
|
gen_kwargs={ |
|
"filepath": data_dir["validation"], |
|
"split": "validation", |
|
}, |
|
), |
|
] |
|
|
|
def _generate_examples( |
|
self, filepath, split |
|
): |
|
""" Yields examples as (key, example) tuples. """ |
|
|
|
|
|
|
|
|
|
with open(filepath, encoding="utf-8") as f: |
|
for id_, row in enumerate(f): |
|
data = json.loads(row) |
|
yield id_, { |
|
"sportsett_id": data["sportsett_id"], |
|
"gem_id": data["gem_id"], |
|
"game": data["game"], |
|
"teams": data["teams"], |
|
"summaries": data["summaries"], |
|
} |
|
|