# 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. """Only Connect Wall (OCW) dataset""" import json import os import datasets _CITATION = """\ @article{Naeini2023LargeLM, title = {Large Language Models are Fixated by Red Herrings: Exploring Creative Problem Solving and Einstellung Effect using the Only Connect Wall Dataset}, author = {Saeid Alavi Naeini and Raeid Saqur and Mozhgan Saeidi and John Giorgi and Babak Taati}, year = 2023, journal = {ArXiv}, volume = {abs/2306.11167}, url = {https://api.semanticscholar.org/CorpusID:259203717} } """ _DESCRIPTION = """\ The Only Connect Wall (OCW) dataset contains 618 "Connecting Walls" from the Round 3: Connecting Wall segment of the Only Connect quiz show, collected from 15 seasons' worth of episodes. Each wall contains the ground-truth groups and connections as well as recorded human performance. """ _HOMEPAGE_URL = "https://github.com/TaatiTeam/OCW/" _LICENSE = "MIT" _BASE_URL = "https://huggingface.co/datasets/TaatiTeam/OCW/resolve/main/" _URLS = { "ocw_train": _BASE_URL + "train.json", "ocw_validation": _BASE_URL + "validation.json", "ocw_test": _BASE_URL + "test.json", "ocw_randomized_test": _BASE_URL + "easy_test_randomized.json", "ocw_wordnet_train": _BASE_URL + "easy_train_wordnet.json", "ocw_wordnet_validation": _BASE_URL + "easy_validation_wordnet.json", "ocw_wordnet_test": _BASE_URL + "easy_test_wordnet.json" } class OCW(datasets.GeneratorBasedBuilder): """OCW dataset""" VERSION = datasets.Version("1.0.0") BUILDER_CONFIGS = [ datasets.BuilderConfig(name="ocw", version=VERSION, description="main OCW dataset"), datasets.BuilderConfig(name="ocw_randomized", version=VERSION, description="Easy OCW dataset with randomized groups in each wall"), datasets.BuilderConfig(name="ocw_wordnet", version=VERSION, description="Easy OCW dataset with wordnet synonyms replaced with original clues") ] DEFAULT_CONFIG_NAME = "ocw" def _info(self): features = datasets.Features( { # "total_walls_in_season": datasets.Value("int32"), # "season_start_date": datasets.Value("string"), # "season_end_date": datasets.Value("string"), "wall_id": datasets.Value("string"), "season": datasets.Value("int32"), "episode": datasets.Value("int32"), "words": datasets.Value("string"), "gt_connections": datasets.Value("string"), "group_1": { "group_id": datasets.Value("string"), "gt_words": datasets.Value("string"), "gt_connection": datasets.Value("string"), "human_performance": { "grouping": datasets.Value("int32"), "connection": datasets.Value("int32") } }, "group_2": { "group_id": datasets.Value("string"), "gt_words": datasets.Value("string"), "gt_connection": datasets.Value("string"), "human_performance": { "grouping": datasets.Value("int32"), "connection": datasets.Value("int32") } }, "group_3": { "group_id": datasets.Value("string"), "gt_words": datasets.Value("string"), "gt_connection": datasets.Value("string"), "human_performance": { "grouping": datasets.Value("int32"), "connection": datasets.Value("int32") } }, "group_4": { "group_id": datasets.Value("string"), "gt_words": datasets.Value("string"), "gt_connection": datasets.Value("string"), "human_performance": { "grouping": datasets.Value("int32"), "connection": datasets.Value("int32") } }, } ) return datasets.DatasetInfo( # This is the description that will appear on the datasets page. description=_DESCRIPTION, # This defines the different columns of the dataset and their types features= features, # Homepage of the dataset for documentation homepage=_HOMEPAGE_URL, # License for the dataset if available license=_LICENSE, # Citation for the dataset citation=_CITATION, # No default supervised_keys supervised_keys=None ) def _split_generators(self, dl_manager): test_url = _URLS[self.config.name + '_test'] # only test set is randomized for ablation studies if self.config.name == 'ocw_randomized': train_url = _URLS['ocw_train'] validation_url = _URLS['ocw_validation'] else: train_url = _URLS[self.config.name + '_train'] validation_url = _URLS[self.config.name + '_validation'] train_path = dl_manager.download_and_extract(train_url) validation_path = dl_manager.download_and_extract(validation_url) test_path = dl_manager.download_and_extract(test_url) return [ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": train_path}), datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": validation_path}), datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": test_path}), ] def _generate_examples(self, filepath): """This function returns the examples in the raw (text) form.""" key = 0 with open(filepath, encoding="utf-8") as f: ocw = json.load(f) for data in ocw["dataset"]: wall_id = data.get("wall_id") season = data.get("season") # season_to_walls_map = ocw['season_to_walls_map'][str(season)] # total_walls_in_season = season_to_walls_map["num_walls"] # season_start_date = season_to_walls_map["start_date"] # season_end_date = season_to_walls_map["end_date"] episode = data.get("episode") words = data.get("words") gt_connections = data.get("gt_connections") group_1 = data['groups']['group_1'] group_1_human_performance = group_1['human_performance'] group_2 = data['groups']['group_2'] group_2_human_performance = group_2['human_performance'] group_3 = data['groups']['group_3'] group_3_human_performance = group_3['human_performance'] group_4 = data['groups']['group_4'] group_4_human_performance = group_4['human_performance'] yield key, { # "total_walls_in_season": total_walls_in_season, # "season_start_date": season_start_date, # "season_end_date": season_end_date, "wall_id": wall_id, "season": season, "episode": episode, "words": words, "gt_connections": gt_connections, "group_1": { "group_id": group_1.get("group_id"), "gt_words": group_1.get("gt_words"), "gt_connection": group_1.get("gt_connection"), "human_performance": { "grouping": group_1_human_performance.get("grouping"), "connection": group_1_human_performance.get("connection") } }, "group_2": { "group_id": group_2.get("group_id"), "gt_words": group_2.get("gt_words"), "gt_connection": group_2.get("gt_connection"), "human_performance": { "grouping": group_2_human_performance.get("grouping"), "connection": group_2_human_performance.get("connection") } }, "group_3": { "group_id": group_3.get("group_id"), "gt_words": group_3.get("gt_words"), "gt_connection": group_3.get("gt_connection"), "human_performance": { "grouping": group_3_human_performance.get("grouping"), "connection": group_3_human_performance.get("connection") } }, "group_4": { "group_id": group_4.get("group_id"), "gt_words": group_4.get("gt_words"), "gt_connection": group_4.get("gt_connection"), "human_performance": { "grouping": group_4_human_performance.get("grouping"), "connection": group_4_human_performance.get("connection") } }, } key += 1