Upload events_classification_biotech.py
Browse files
events_classification_biotech.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
-
import pandas as pd
|
2 |
import datasets
|
|
|
3 |
from datasets.tasks import TextClassification
|
4 |
|
5 |
DESCRIPTION = """
|
@@ -75,25 +75,15 @@ class BiotechNews(datasets.GeneratorBasedBuilder):
|
|
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 =
|
90 |
-
for
|
91 |
-
|
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)
|
|
|
|
|
1 |
import datasets
|
2 |
+
from datasets import load_dataset
|
3 |
from datasets.tasks import TextClassification
|
4 |
|
5 |
DESCRIPTION = """
|
|
|
75 |
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": test_path}),
|
76 |
]
|
77 |
|
|
|
|
|
|
|
|
|
|
|
78 |
def get_all_labels(self, curr_labels):
|
79 |
curr_labels = [lbl for lbl in curr_labels if lbl]
|
80 |
all_curr_labels = ', '.join(curr_labels)
|
81 |
return all_curr_labels
|
82 |
|
83 |
def _generate_examples(self, filepath):
|
84 |
+
csv_reader = load_dataset('csv',data_files=filepath, split='train')
|
85 |
+
for example in csv_reader:
|
86 |
+
id_, title, content, organization, label1, label2, label3, label4, label5 = example.values()
|
|
|
|
|
|
|
|
|
|
|
87 |
|
88 |
curr_labels = (label1, label2, label3, label4, label5)
|
89 |
all_curr_labels = self.get_all_labels(curr_labels)
|