|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
""" |
|
Arguement Mining Dataset created by Stab , Gurevych et. al. CL 2017 |
|
""" |
|
|
|
import datasets |
|
import os |
|
|
|
|
|
_CITATION = """\ |
|
@article{stab2017parsing, |
|
title={Parsing argumentation structures in persuasive essays}, |
|
author={Stab, Christian and Gurevych, Iryna}, |
|
journal={Computational Linguistics}, |
|
volume={43}, |
|
number={3}, |
|
pages={619--659}, |
|
year={2017}, |
|
publisher={MIT Press One Rogers Street, Cambridge, MA 02142-1209, USA journals-info~…} |
|
} |
|
""" |
|
|
|
_DESCRIPTION = """\ |
|
tokens along with chunk id. IOB1 format Begining of arguement denoted by B-ARG,inside arguement |
|
denoted by I-ARG, other chunks are O |
|
Orginial train,test split as used by the paper is provided |
|
""" |
|
|
|
_URL = "https://raw.githubusercontent.com/Sam131112/Argument-Mining-Dataset/main/" |
|
_TRAINING_FILE = "train.txt" |
|
_TEST_FILE = "test.txt" |
|
|
|
|
|
class ArguementMiningCL2017Config(datasets.BuilderConfig): |
|
"""BuilderConfig for CL2017""" |
|
|
|
def __init__(self, **kwargs): |
|
"""BuilderConfig forCl2017. |
|
Args: |
|
**kwargs: keyword arguments forwarded to super. |
|
""" |
|
super(ArguementMiningCL2017Config, self).__init__(**kwargs) |
|
|
|
|
|
class ArguementMiningCL2017(datasets.GeneratorBasedBuilder): |
|
"""CL2017 dataset.""" |
|
|
|
BUILDER_CONFIGS = [ |
|
ArguementMiningCL2017Config(name="cl2017", version=datasets.Version("1.0.0"), description="Cl2017 dataset"), |
|
] |
|
|
|
def _info(self): |
|
return datasets.DatasetInfo( |
|
description=_DESCRIPTION, |
|
features=datasets.Features( |
|
{ |
|
"id": datasets.Value("string"), |
|
"tokens": datasets.Sequence(datasets.Value("string")), |
|
"chunk_tags":datasets.Sequence( |
|
datasets.features.ClassLabel( |
|
names=[ |
|
"O", |
|
"B-ARG", |
|
"I-ARG", |
|
] |
|
) |
|
), |
|
} |
|
), |
|
supervised_keys=None, |
|
homepage="https://direct.mit.edu/coli/article/43/3/619/1573/Parsing-Argumentation-Structures-in-Persuasive", |
|
citation=_CITATION, |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
"""Returns SplitGenerators.""" |
|
urls_to_download = { |
|
"train": _TRAINING_FILE, |
|
"test": _TEST_FILE, |
|
} |
|
downloaded_files = dl_manager.download_and_extract(urls_to_download) |
|
|
|
return [ |
|
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}), |
|
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloaded_files["test"]}), |
|
] |
|
|
|
def _generate_examples(self, filepath): |
|
print("⏳ Generating examples from = %s", filepath) |
|
with open(filepath, encoding="utf-8") as f: |
|
guid = 0 |
|
tokens = [] |
|
pos_tags = [] |
|
chunk_tags = [] |
|
ner_tags = [] |
|
for line in f: |
|
if line == "\n": |
|
if tokens: |
|
yield guid, { |
|
"id": str(guid), |
|
"tokens": tokens, |
|
"chunk_tags": chunk_tags, |
|
} |
|
guid = ' ' |
|
tokens = [] |
|
chunk_tags = [] |
|
else: |
|
|
|
line=line.strip('\n') |
|
splits = line.split("\t") |
|
print(splits) |
|
guid = splits[0] |
|
tokens.append(splits[1]) |
|
chunk_tags.append(splits[2]) |
|
|
|
|
|
yield guid, { |
|
"id": str(guid), |
|
"tokens": tokens, |
|
"chunk_tags": chunk_tags, |
|
} |
|
|