File size: 3,973 Bytes
2e32ef3 503efff 2e32ef3 504145a 2e32ef3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# 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.
"""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__)
# --------------------------------------------------------------------------------------------------------
# Tag set
_LABELS = [
"O", # non-entities label
"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), # hf dataset script 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"]):
# example features: document_id, tokens, labels
yield idx, example
|