Ihor commited on
Commit
a6842d0
1 Parent(s): da232db

initial commit

Browse files
Files changed (3) hide show
  1. biotech_news.py +104 -0
  2. test.csv +0 -0
  3. train.csv +0 -0
biotech_news.py ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import datasets
3
+ from datasets.tasks import TextClassification
4
+
5
+ DESCRIPTION = """
6
+ Text classification is a widespread task and a foundational step in numerous information extraction pipelines. However, a notable challenge in current NLP research lies in the oversimplification of benchmarking datasets, which predominantly focus on rudimentary tasks such as topic classification or sentiment analysis.
7
+
8
+ This dataset is specifically curated to address the limitations of existing benchmarks by incorporating rich and complex content derived from the biotech domain. It encompasses diverse biotech news articles and events, offering a more nuanced perspective on information extraction challenges. Unlike conventional datasets, our collection goes beyond basic categorization, delving into the realm of multi-label classification.
9
+
10
+ A distinctive feature of this dataset is its emphasis on not only identifying the overarching theme but also extracting information about the target companies associated with the news. This dual-layered approach enhances the dataset's utility for applications that require a deeper understanding of the relationships between events, companies, and the biotech industry as a whole.
11
+ """
12
+
13
+ labels = ['event organization',
14
+ 'executive statement',
15
+ 'regulatory approval',
16
+ 'hiring',
17
+ 'foundation',
18
+ 'closing',
19
+ 'partnerships & alliances',
20
+ 'expanding industry',
21
+ 'new initiatives or programs',
22
+ 'm&a',
23
+ None,
24
+ 'service & product providing',
25
+ 'event organisation',
26
+ 'new initiatives & programs',
27
+ 'subsidiary establishment',
28
+ 'product launching & presentation',
29
+ 'product updates',
30
+ 'executive appointment',
31
+ 'alliance & partnership',
32
+ 'ipo exit',
33
+ 'article publication',
34
+ 'clinical trial sponsorship',
35
+ 'company description',
36
+ 'investment in public company',
37
+ 'other',
38
+ 'expanding geography',
39
+ 'participation in an event',
40
+ 'support & philanthropy',
41
+ 'department establishment',
42
+ 'funding round',
43
+ 'patent publication']
44
+
45
+ TRAIN_DOWNLOAD_URL = "https://huggingface.co/datasets/knowledgator/events_classification_biotech/raw/main/train.csv"
46
+ TEST_DOWNLOAD_URL = "https://huggingface.co/datasets/knowledgator/events_classification_biotech/raw/main/test.csv"
47
+
48
+ class BiotechNews(datasets.GeneratorBasedBuilder):
49
+ """Biotech news events classification dataset."""
50
+
51
+ def _info(self):
52
+ return datasets.DatasetInfo(
53
+ description=DESCRIPTION,
54
+ features=datasets.Features(
55
+ {
56
+ "title": datasets.Value("string"),
57
+ "content": datasets.Value("string"),
58
+ "target organization": datasets.Value("string"),
59
+ "all_labels": datasets.Value("string"),
60
+ "label 1": datasets.features.ClassLabel(names=labels),
61
+ "label 2": datasets.features.ClassLabel(names=labels),
62
+ "label 3": datasets.features.ClassLabel(names=labels),
63
+ "label 4": datasets.features.ClassLabel(names=labels),
64
+ "label 5": datasets.features.ClassLabel(names=labels),
65
+
66
+ }
67
+ ),
68
+ )
69
+
70
+ def _split_generators(self, dl_manager):
71
+ train_path = dl_manager.download_and_extract(TRAIN_DOWNLOAD_URL)
72
+ test_path = dl_manager.download_and_extract(TEST_DOWNLOAD_URL)
73
+ return [
74
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": train_path}),
75
+ datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": test_path}),
76
+ ]
77
+
78
+ def convert_to_none(self, label):
79
+ if type(label) == float:
80
+ label = None
81
+ return label
82
+
83
+ def get_all_labels(self, curr_labels):
84
+ curr_labels = [lbl for lbl in curr_labels if lbl]
85
+ all_curr_labels = ', '.join(curr_labels)
86
+ return all_curr_labels
87
+
88
+ def _generate_examples(self, filepath):
89
+ csv_reader = pd.read_csv(filepath)
90
+ for id_, row in csv_reader.iterrows():
91
+ i, title, content, organization, label1, label2, label3, label4, label5 = row
92
+ label1 = self.convert_to_none(label1)
93
+ label2 = self.convert_to_none(label2)
94
+ label3 = self.convert_to_none(label3)
95
+ label4 = self.convert_to_none(label4)
96
+ label5 = self.convert_to_none(label5)
97
+
98
+ curr_labels = (label1, label2, label3, label4, label5)
99
+ all_curr_labels = self.get_all_labels(curr_labels)
100
+
101
+ yield id_, {"title": title, "content": content, "target organization": organization,
102
+ "all_labels": all_curr_labels,
103
+ "label 1": label1, "label 2": label2, "label 3": label3, "label 4": label4,
104
+ "label 5": label5}
test.csv ADDED
The diff for this file is too large to render. See raw diff
 
train.csv ADDED
The diff for this file is too large to render. See raw diff