|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""TODO: Add a description here.""" |
|
|
|
|
|
import csv |
|
import json |
|
import jsonlines |
|
import os |
|
|
|
import datasets |
|
from datasets import Features |
|
|
|
|
|
_CITATION = """\ |
|
@inproceedings{Zhu2023FIREBALL, |
|
title={{FIREBALL: A Dataset of Dungeons and Dragons Actual-Play with Structured Game State Information}}, |
|
author={Zhu, Andrew and Aggarwal, Karmanya and Feng, Alexander and Martin, Lara J. and Callison-Burch, Chris}, |
|
year={2023}, |
|
booktitle={Annual Meeting of the Association for Computational Linguistics (ACL)}, |
|
month={7}, |
|
url={https://aclanthology.org/2023.acl-long.229/}, |
|
address={Toronto, Canada}, |
|
pages={4171--4193}, |
|
publisher={ACL}, |
|
doi={10.18653/v1/2023.acl-long.229} |
|
} |
|
""" |
|
_DESCRIPTION = """\ |
|
FIREBALL Dungeons & Dragons data with narrative and Avrae scripting commands. |
|
""" |
|
_HOMEPAGE = "https://github.com/zhudotexe/FIREBALL" |
|
_LICENSE = "cc-by-4.0" |
|
_URLS = { |
|
"FIREBALL": "https://huggingface.co/datasets/lara-martin/FIREBALL/raw/main/" |
|
} |
|
|
|
class Fireball(datasets.GeneratorBasedBuilder): |
|
"""TODO: Short description of my dataset.""" |
|
|
|
VERSION = datasets.Version("1.0.0") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BUILDER_CONFIGS = [ |
|
datasets.BuilderConfig(name="FIREBALL", version=VERSION), |
|
] |
|
|
|
|
|
def _info(self): |
|
|
|
features = Features( |
|
{ |
|
"speaker_id": datasets.Value('int64'), |
|
"before_utterances": datasets.Sequence(datasets.Value('string')), |
|
'combat_state_before': datasets.Sequence( |
|
{ |
|
'name': datasets.Value(dtype='string'), |
|
'hp': datasets.Value(dtype='string'), |
|
'class': datasets.Value(dtype='string'), |
|
'race': datasets.Value(dtype='string'), |
|
'attacks': datasets.Value(dtype='string'), |
|
'spells': datasets.Value(dtype='string'), |
|
'actions': datasets.Value(dtype='string'), |
|
'effects': datasets.Value(dtype='string'), |
|
'description': datasets.Value(dtype='string'), |
|
'controller_id': datasets.Value(dtype='string') |
|
} |
|
), |
|
'current_actor': { |
|
'name': datasets.Value(dtype='string'), |
|
'hp': datasets.Value(dtype='string'), |
|
'class': datasets.Value(dtype='string'), |
|
'race': datasets.Value(dtype='string'), |
|
'attacks': datasets.Value(dtype='string'), |
|
'spells': datasets.Value(dtype='string'), |
|
'actions': datasets.Value(dtype='string'), |
|
'effects': datasets.Value(dtype='string'), |
|
'description': datasets.Value(dtype='string'), |
|
'controller_id': datasets.Value(dtype='string') |
|
}, |
|
'commands_norm': datasets.Value('string'), |
|
'automation_results': datasets.Value('string'), |
|
'caster_after': { |
|
'name': datasets.Value(dtype='string'), |
|
'hp': datasets.Value(dtype='string'), |
|
'class': datasets.Value(dtype='string'), |
|
'race': datasets.Value(dtype='string'), |
|
'attacks': datasets.Value(dtype='string'), |
|
'spells': datasets.Value(dtype='string'), |
|
'actions': datasets.Value(dtype='string'), |
|
'effects': datasets.Value(dtype='string'), |
|
'description': datasets.Value(dtype='string'), |
|
'controller_id': datasets.Value(dtype='string') |
|
}, |
|
'targets_after': datasets.Sequence( |
|
{ |
|
'name': datasets.Value(dtype='string'), |
|
'hp': datasets.Value(dtype='string'), |
|
'class': datasets.Value(dtype='string'), |
|
'race': datasets.Value(dtype='string'), |
|
'attacks': datasets.Value(dtype='string'), |
|
'spells': datasets.Value(dtype='string'), |
|
'actions': datasets.Value(dtype='string'), |
|
'effects': datasets.Value(dtype='string'), |
|
'description': datasets.Value(dtype='string'), |
|
'controller_id': datasets.Value(dtype='string') |
|
} |
|
), |
|
'combat_state_after': datasets.Sequence( |
|
{ |
|
'name': datasets.Value(dtype='string'), |
|
'hp': datasets.Value(dtype='string'), |
|
'class': datasets.Value(dtype='string'), |
|
'race': datasets.Value(dtype='string'), |
|
'attacks': datasets.Value(dtype='string'), |
|
'spells': datasets.Value(dtype='string'), |
|
'actions': datasets.Value(dtype='string'), |
|
'effects': datasets.Value(dtype='string'), |
|
'description': datasets.Value(dtype='string'), |
|
'controller_id': datasets.Value(dtype='string') |
|
} |
|
), |
|
'after_utterances': datasets.Sequence(datasets.Value('string')), |
|
'utterance_history': datasets.Sequence(datasets.Value('string')), |
|
'before_idxs': datasets.Sequence(datasets.Value('int16')), |
|
'before_state_idx': datasets.Value('int16'), |
|
'command_idxs': datasets.Sequence(datasets.Value('int16')), |
|
'after_state_idx': datasets.Value('int16'), |
|
'after_idxs': datasets.Sequence(datasets.Value('int16')), |
|
'embed_idxs': datasets.Sequence(datasets.Value('int16')) |
|
} |
|
) |
|
return datasets.DatasetInfo( |
|
|
|
description=_DESCRIPTION, |
|
|
|
features=features, |
|
|
|
|
|
|
|
|
|
homepage=_HOMEPAGE, |
|
|
|
license=_LICENSE, |
|
|
|
citation=_CITATION, |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
|
|
|
|
url = _URLS[self.config.name] |
|
|
|
|
|
|
|
file_list = dl_manager.download(url+"files.txt") |
|
with open(file_list) as f: |
|
data_filenames = [line.strip() for line in f if line] |
|
data_urls = dl_manager.download([url+"filtered/"+data_filename for data_filename in data_filenames]) |
|
|
|
downloaded_files = dl_manager.download(data_urls) |
|
return [ |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TRAIN, |
|
|
|
gen_kwargs={ |
|
"filepath": downloaded_files |
|
}, |
|
), |
|
] |
|
|
|
|
|
def _generate_examples(self, filepath): |
|
|
|
|
|
key = 0 |
|
for file in filepath: |
|
with jsonlines.open(file) as f: |
|
for data in f: |
|
|
|
yield key, { |
|
"speaker_id": data["speaker_id"], |
|
"before_utterances": data["before_utterances"], |
|
'combat_state_before': data['combat_state_before'], |
|
'current_actor': data["current_actor"], |
|
'commands_norm': data['commands_norm'], |
|
'automation_results': data['automation_results'], |
|
'caster_after': data['caster_after'], |
|
'targets_after': data['targets_after'], |
|
'combat_state_after': data['combat_state_after'], |
|
'after_utterances': data['after_utterances'], |
|
'utterance_history': data['utterance_history'], |
|
'before_idxs': data['before_idxs'], |
|
'before_state_idx': data['before_state_idx'], |
|
'command_idxs': data['command_idxs'], |
|
'after_state_idx': data['after_state_idx'], |
|
'after_idxs': data['after_idxs'], |
|
'embed_idxs': data['embed_idxs'] |
|
} |
|
key+=1 |
|
|