Convert dataset to Parquet
#5
by albertvillanova HF Staff - opened
Files changed (10)
- README.md+52-30
- channel_two/all_-00000-of-00001.parquetAdded+3
- channel_two/dev-00000-of-00001.parquetAdded+3
- channel_two/pilot-00000-of-00001.parquetAdded+3
- channel_two/pilot_dev-00000-of-00001.parquetAdded+3
- channel_two/test-00000-of-00001.parquetAdded+3
- irc_disentangle.pyDeleted-272
- ubuntu/test-00000-of-00001.parquetAdded+3
- ubuntu/train-00000-of-00001.parquetAdded+3
- ubuntu/validation-00000-of-00001.parquetAdded+3
20 unmodified lines212223242526273 unmodified lines31323334353637383940414243444546474849505152533 unmodified lines575859606162636465666768697071727374757677787980818220 unmodified linestags:- conversation-disentanglementdataset_info:- config_name: ubuntufeatures:- name: iddtype: int323 unmodified linesdtype: string- name: tokenizeddtype: string- name: datedtype: string- name: connectionssequence: int32splits:- name: trainnum_bytes: 56012854num_examples: 220616- name: validationnum_bytes: 3081479num_examples: 12510- name: testnum_bytes: 3919900num_examples: 15010download_size: 118470210dataset_size: 63014233- config_name: channel_twofeatures:- name: iddtype: int323 unmodified linesdtype: string- name: tokenizeddtype: string- name: connectionssequence: int32splits:- name: devnum_bytes: 197505num_examples: 1001- name: pilotnum_bytes: 92663num_examples: 501- name: testnum_bytes: 186823num_examples: 1001- name: pilot_devnum_bytes: 290175num_examples: 1501- name: all_num_bytes: 496524num_examples: 2602download_size: 118470210dataset_size: 1263690---20 unmodified lines212223242526273 unmodified lines3132333435363738394041424344454647484950515253545556573 unmodified lines61626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310420 unmodified linestags:- conversation-disentanglementdataset_info:- config_name: channel_twofeatures:- name: iddtype: int323 unmodified linesdtype: string- name: tokenizeddtype: string- name: connectionssequence: int32splits:- name: devnum_bytes: 197173num_examples: 1001- name: pilotnum_bytes: 92498num_examples: 501- name: testnum_bytes: 186478num_examples: 1001- name: pilot_devnum_bytes: 289679num_examples: 1501- name: all_num_bytes: 495650num_examples: 2602download_size: 715946dataset_size: 1261478- config_name: ubuntufeatures:- name: iddtype: int323 unmodified linesdtype: string- name: tokenizeddtype: string- name: datedtype: string- name: connectionssequence: int32splits:- name: trainnum_bytes: 55970012num_examples: 220616- name: validationnum_bytes: 3079320num_examples: 12510- name: testnum_bytes: 3916841num_examples: 15010download_size: 33214005dataset_size: 62966173configs:- config_name: channel_twodata_files:- split: devpath: channel_two/dev-*- split: pilotpath: channel_two/pilot-*- split: testpath: channel_two/test-*- split: pilot_devpath: channel_two/pilot_dev-*- split: all_path: channel_two/all_-*- config_name: ubuntudata_files:- split: trainpath: ubuntu/train-*- split: validationpath: ubuntu/validation-*- split: testpath: ubuntu/test-*default: true---
123version https://git-lfs.github.com/spec/v1oid sha256:acac7a02cc3fe4fa7f8e14da48c88257422182dc1a10c248f13194bda6d813f1size 279315123version https://git-lfs.github.com/spec/v1oid sha256:b5d9801fd53eb530b5e2e04cbfd05f916f0801a949250109acdc95409f2a8e7fsize 109403123version https://git-lfs.github.com/spec/v1oid sha256:4b1a53149116d939384b372a4506c38a7b17da82082e96d4dea4a08daa82e929size 55912123version https://git-lfs.github.com/spec/v1oid sha256:2f1b2b0356a52dffb8abe2fd864e7ef2aeae03e0462cd97d2b434a3a0bb6020esize 161875123version https://git-lfs.github.com/spec/v1oid sha256:b74b04a577d4974a09c879a1b9c50f0434d857155d7aa9d59e94d0ba6fa5efd3size 109441123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272# coding=utf-8# 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."""Dataset of disentangled IRC"""
import globimport osfrom pathlib import Path
import datasets
_CITATION = """\@inproceedings{kummerfeld-etal-2019-large, title = "A Large-Scale Corpus for Conversation Disentanglement", author = "Kummerfeld, Jonathan K. and Gouravajhala, Sai R. and Peper, Joseph J. and Athreya, Vignesh and Gunasekara, Chulaka and Ganhotra, Jatin and Patel, Siva Sankalp and Polymenakos, Lazaros C and Lasecki, Walter", booktitle = "Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics", month = jul, year = "2019", address = "Florence, Italy", publisher = "Association for Computational Linguistics", url = "https://aclanthology.org/P19-1374", doi = "10.18653/v1/P19-1374", pages = "3846--3856", arxiv = "https://arxiv.org/abs/1810.11118", software = "https://jkk.name/irc-disentanglement", data = "https://jkk.name/irc-disentanglement", abstract = "Disentangling conversations mixed together in a single stream of messages is a difficult task, made harder by the lack of large manually annotated datasets. We created a new dataset of 77,563 messages manually annotated with reply-structure graphs that both disentangle conversations and define internal conversation structure. Our data is 16 times larger than all previously released datasets combined, the first to include adjudication of annotation disagreements, and the first to include context. We use our data to re-examine prior work, in particular, finding that 89% of conversations in a widely used dialogue corpus are either missing messages or contain extra messages. Our manually-annotated data presents an opportunity to develop robust data-driven methods for conversation disentanglement, which will help advance dialogue research.",}"""
_DESCRIPTION = """\Disentangling conversations mixed together in a single stream of messages isa difficult task, made harder by the lack of large manually annotateddatasets. This new dataset of 77,563 messages manually annotated withreply-structure graphs that both disentangle conversations and defineinternal conversation structure. The dataset is 16 times larger than allpreviously released datasets combined, the first to include adjudication ofannotation disagreements, and the first to include context."""
_HOMEPAGE = "https://jkk.name/irc-disentanglement/"
_LICENSE = "Creative Commons Attribution 4.0 International Public License"
_URL = "https://github.com/jkkummerfeld/irc-disentanglement/archive/refs/heads/master.zip"
class IRCDisentangle(datasets.GeneratorBasedBuilder): """IRCDisentangle dataset"""
VERSION = datasets.Version("1.0.0")
BUILDER_CONFIGS = [ datasets.BuilderConfig( name="ubuntu", version=VERSION, description="This part of the dataset is the annotated conversations from the Ubuntu channel", ), datasets.BuilderConfig( name="channel_two", version=VERSION, description="This part of the dataset is the annotated conversations from the Channel Two", ), ]
DEFAULT_CONFIG_NAME = "ubuntu"
def _info(self): if self.config.name == "ubuntu": features = datasets.Features( { "id": datasets.Value("int32"), "raw": datasets.Value("string"), "ascii": datasets.Value("string"), "tokenized": datasets.Value("string"), "date": datasets.Value("string"), "connections": datasets.features.Sequence(datasets.Value("int32")), } ) elif self.config.name == "channel_two": features = datasets.Features( { "id": datasets.Value("int32"), "raw": datasets.Value("string"), "ascii": datasets.Value("string"), "tokenized": datasets.Value("string"), "connections": datasets.features.Sequence(datasets.Value("int32")), } ) return datasets.DatasetInfo( description=_DESCRIPTION, features=features, supervised_keys=None, homepage=_HOMEPAGE, license=_LICENSE, citation=_CITATION, )
def _split_generators(self, dl_manager): """Returns SplitGenerators.""" dl_dir = dl_manager.download_and_extract(_URL) filepath = os.path.join(dl_dir, "irc-disentanglement-master", "data") split_names = {datasets.Split.TRAIN: "train", datasets.Split.VALIDATION: "dev", datasets.Split.TEST: "test"} if self.config.name == "ubuntu": return [ datasets.SplitGenerator( name=split, gen_kwargs={ "filepath": os.path.join(filepath, split_name), "split": split_name, }, ) for split, split_name in split_names.items() ] elif self.config.name == "channel_two": filepath = os.path.join(filepath, "channel-two") return [ datasets.SplitGenerator( name="dev", gen_kwargs={ "filepath": filepath, "split": "dev", }, ), datasets.SplitGenerator( name="pilot", gen_kwargs={ "filepath": filepath, "split": "pilot", }, ), datasets.SplitGenerator( name="test", gen_kwargs={ "filepath": filepath, "split": "test", }, ), datasets.SplitGenerator( name="pilot_dev", gen_kwargs={ "filepath": filepath, "split": "pilot-dev", }, ), datasets.SplitGenerator( name="all_", gen_kwargs={ "filepath": filepath, "split": "all", }, ), ]
def _generate_examples(self, filepath, split): """Yields examples."""
if self.config.name == "ubuntu": # run loop for each date all_files = sorted(glob.glob(os.path.join(filepath, "*.annotation.txt"))) all_dates = [Path(filename).name[:10] for filename in all_files] all_info = [Path(filename).name[10:-15] for filename in all_files]
elif self.config.name == "channel_two": # run loop once (there are no dates for this config) all_dates = ["_"] all_info = ["_"]
last_id = 0 id_ = 0
for date, info in zip(all_dates, all_info):
if self.config.name == "ubuntu": # load file of given date and additional info for each split raw_path = os.path.join(filepath, f"{date}{info}.raw.txt") ascii_path = os.path.join(filepath, f"{date}{info}.ascii.txt") tok_path = os.path.join(filepath, f"{date}{info}.tok.txt") annot_path = os.path.join(filepath, f"{date}{info}.annotation.txt")
elif self.config.name == "channel_two": # load files of different splits raw_path = os.path.join(filepath, f"channel-two.{split}.raw.txt") ascii_path = os.path.join(filepath, f"channel-two.{split}.ascii.txt") tok_path = os.path.join(filepath, f"channel-two.{split}.tok.txt") annot_path = os.path.join(filepath, f"channel-two.{split}.annotation.txt")
with open(raw_path, encoding="utf-8") as f_raw, open(ascii_path, encoding="utf-8") as f_ascii, open( tok_path, encoding="utf-8" ) as f_tok, open(annot_path, encoding="utf-8") as f_annot:
# tokenize txt file raw_sentences = f_raw.read().split("\n") ascii_sentences = f_ascii.read().split("\n") tok_sentences = f_tok.read().split("\n") annot_lines = f_annot.read().split("\n")
assert ( len(raw_sentences) == len(ascii_sentences) == len(tok_sentences) ), "Sizes do not match: %d vs %d vs %d for Raw Sentences vs Ascii Sentences vs Tokenized Sentences." % ( len(raw_sentences), len(ascii_sentences), len(tok_sentences), )
annotation_pairs = []
# for annotation lines, make annotation pairs for annot in annot_lines: line = annot.split(" ") if len(line) > 1: annotation_pairs.append((int(line[0]), int(line[1])))
annotations = dict() for row in range(last_id, last_id + len(raw_sentences)): annotations[row] = set()
for (a, b) in annotation_pairs: # required for dummy data creation if last_id + a not in annotations: annotations[last_id + a] = set() if last_id + b not in annotations: annotations[last_id + b] = set()
# add annotation 'b' to a's annotation set, and vice versa annotations[last_id + a].add(last_id + b) annotations[last_id + b].add(last_id + a)
for i in range(len(raw_sentences)): # return all 3 kinds of chat messages, the date (if applicable), and the annotation set for that sentece if self.config.name == "ubuntu": yield id_, { "id": id_, "raw": raw_sentences[i], "ascii": ascii_sentences[i], "tokenized": tok_sentences[i], "date": date, "connections": sorted(annotations[id_]), } elif self.config.name == "channel_two": yield id_, { "id": id_, "raw": raw_sentences[i], "ascii": ascii_sentences[i], "tokenized": tok_sentences[i], "connections": sorted(annotations[i]), } id_ += 1
# continue counting from position last left off last_id = id_123version https://git-lfs.github.com/spec/v1oid sha256:a6a3a4dec7f1cfe05fd47a5b00ec5969cff5a53e33f3120a3b5d522ed3e88c83size 2116104123version https://git-lfs.github.com/spec/v1oid sha256:a7ef4cc537e2c88d3202e2404b7dc76df177856a94d6edaedd89b418ab896d52size 29452339123version https://git-lfs.github.com/spec/v1oid sha256:a5aeada72085ce29c5f24127918bc9255665f3be0a5112568d504be903741d80size 1645562README.md+52-30
channel_two/all_-00000-of-00001.parquetAdded+3
channel_two/dev-00000-of-00001.parquetAdded+3
channel_two/pilot-00000-of-00001.parquetAdded+3
channel_two/pilot_dev-00000-of-00001.parquetAdded+3
channel_two/test-00000-of-00001.parquetAdded+3
irc_disentangle.pyDeleted-272
ubuntu/test-00000-of-00001.parquetAdded+3
ubuntu/train-00000-of-00001.parquetAdded+3
ubuntu/validation-00000-of-00001.parquetAdded+3