Datasets:
Commit
·
423bea8
1
Parent(s):
863ffbf
Update difraud.py
Browse files- difraud.py +7 -5
difraud.py
CHANGED
@@ -3,6 +3,7 @@ import json
|
|
3 |
import os
|
4 |
import sys
|
5 |
import datasets
|
|
|
6 |
|
7 |
|
8 |
# TODO: Add BibTeX citation
|
@@ -73,17 +74,18 @@ class DIFrauD(datasets.GeneratorBasedBuilder):
|
|
73 |
DEFAULT_CONFIG_NAME = "phishing"
|
74 |
|
75 |
def _info(self):
|
76 |
-
|
77 |
-
features = self.config
|
78 |
-
)
|
79 |
return datasets.DatasetInfo(
|
|
|
80 |
# This is the description that will appear on the datasets page.
|
81 |
description=_DESCRIPTION,
|
82 |
# This defines the different columns of the dataset and their types
|
83 |
-
features=features, # Here we define them above because they are different between the two configurations
|
84 |
# If there's a common (input, target) tuple from the features, uncomment supervised_keys line below and
|
85 |
# specify them. They'll be used if as_supervised=True in builder.as_dataset.
|
86 |
supervised_keys=("text", "label"),
|
|
|
|
|
87 |
# Homepage of the dataset for documentation
|
88 |
homepage=_HOMEPAGE,
|
89 |
# License for the dataset if available
|
@@ -140,6 +142,6 @@ class DIFrauD(datasets.GeneratorBasedBuilder):
|
|
140 |
data = json.loads(row)
|
141 |
yield key, {
|
142 |
"text": data["text"],
|
143 |
-
"label":
|
144 |
}
|
145 |
|
|
|
3 |
import os
|
4 |
import sys
|
5 |
import datasets
|
6 |
+
from datasets.tasks import TextClassification
|
7 |
|
8 |
|
9 |
# TODO: Add BibTeX citation
|
|
|
74 |
DEFAULT_CONFIG_NAME = "phishing"
|
75 |
|
76 |
def _info(self):
|
77 |
+
|
|
|
|
|
78 |
return datasets.DatasetInfo(
|
79 |
+
config_name=self.config.name,
|
80 |
# This is the description that will appear on the datasets page.
|
81 |
description=_DESCRIPTION,
|
82 |
# This defines the different columns of the dataset and their types
|
83 |
+
features=self.config.features, # Here we define them above because they are different between the two configurations
|
84 |
# If there's a common (input, target) tuple from the features, uncomment supervised_keys line below and
|
85 |
# specify them. They'll be used if as_supervised=True in builder.as_dataset.
|
86 |
supervised_keys=("text", "label"),
|
87 |
+
# specify standard binary classification task for datasets to setup easier
|
88 |
+
task_templates=[TextClassification(text_column="text", label_column="label")],
|
89 |
# Homepage of the dataset for documentation
|
90 |
homepage=_HOMEPAGE,
|
91 |
# License for the dataset if available
|
|
|
142 |
data = json.loads(row)
|
143 |
yield key, {
|
144 |
"text": data["text"],
|
145 |
+
"label": int(data["label"]),
|
146 |
}
|
147 |
|