|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""BUSTER: a BUSiness Transaction Entity Recognition Dataset""" |
|
|
|
import os |
|
import datasets |
|
from datasets import load_dataset |
|
|
|
_CITATION = """ |
|
Accepted at EMNLP 2023 - Industry Track. |
|
TBA |
|
""" |
|
|
|
_DESCRIPTION = """ |
|
Buster is an Entity Recognition dataset consisting of 3779 manually annotated documents on financial transactions. |
|
Documents were selected using EDGAR (Electronic Data Gathering, Analysis, and Retrieval system) from the |
|
U.S. Securities and Exchange Commission (SEC). |
|
The corpus focuses on the main actors involved in business transactions. |
|
Overall, there are three families of entities: Parties, Advisors and Generic information, for a total of 6 annotated |
|
entity types. |
|
We also released a corpus of 6196 automatically annotated documents. |
|
""" |
|
|
|
_HOMEPAGE = "https://expert.ai/buster" |
|
_URL = "BUSTER.zip" |
|
_VERSION = "1.0.0" |
|
|
|
logger = datasets.logging.get_logger(__name__) |
|
|
|
|
|
|
|
|
|
_LABELS = [ |
|
"O", |
|
"B-Parties.BUYING_COMPANY", |
|
"I-Parties.BUYING_COMPANY", |
|
"B-Parties.SELLING_COMPANY", |
|
"I-Parties.SELLING_COMPANY", |
|
"B-Parties.ACQUIRED_COMPANY", |
|
"I-Parties.ACQUIRED_COMPANY", |
|
"B-Advisors.LEGAL_CONSULTING_COMPANY", |
|
"I-Advisors.LEGAL_CONSULTING_COMPANY", |
|
"B-Advisors.GENERIC_CONSULTING_COMPANY", |
|
"I-Advisors.GENERIC_CONSULTING_COMPANY", |
|
"B-Generic_Info.ANNUAL_REVENUES", |
|
"I-Generic_Info.ANNUAL_REVENUES" |
|
] |
|
|
|
|
|
class BusterConfig(datasets.BuilderConfig): |
|
"""BuilderConfig for the BUSTER dataset.""" |
|
|
|
def __init__(self, **kwargs): |
|
"""BuilderConfig for the BUSTER dataset. |
|
Args: |
|
**kwargs: keyword arguments forwarded to super. |
|
""" |
|
super(BusterConfig, self).__init__( |
|
name=f"BUSTER", |
|
description=_DESCRIPTION, |
|
version=datasets.Version(_VERSION), |
|
**kwargs, |
|
) |
|
|
|
|
|
class Buster(datasets.GeneratorBasedBuilder): |
|
"""The BUSTER dataset.""" |
|
|
|
BUILDER_CONFIGS = [ |
|
BusterConfig() |
|
] |
|
|
|
def _info(self): |
|
return datasets.DatasetInfo( |
|
description=_DESCRIPTION, |
|
features=datasets.Features( |
|
{ |
|
"document_id": datasets.Value("string"), |
|
"tokens": datasets.Sequence(datasets.Value("string")), |
|
"labels": datasets.Sequence(datasets.features.ClassLabel(names=_LABELS)), |
|
} |
|
), |
|
homepage=_HOMEPAGE, |
|
citation=_CITATION, |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
data_dir = dl_manager.download_and_extract(_URL) |
|
fold_names = [f"FOLD_{i}.json" for i in range(1, 6)] + ["SILVER.json"] |
|
return [ |
|
datasets.SplitGenerator( |
|
name=fold_name, |
|
gen_kwargs={"file_path": os.path.join(data_dir, fold_name)}, |
|
) for fold_name in fold_names |
|
] |
|
|
|
def _generate_examples(self, file_path): |
|
dataset = load_dataset("json", data_files=file_path) |
|
logger.info(f"Generating examples from: {file_path}") |
|
for idx, example in enumerate(dataset["train"]): |
|
|
|
yield idx, example |
|
|