Datasets:
Tasks:
Text Classification
Modalities:
Text
Formats:
text
Sub-tasks:
sentiment-classification
Languages:
English
Size:
1M - 10M
License:
Update HF_dataset.py
Browse files- HF_dataset.py +6 -5
HF_dataset.py
CHANGED
|
@@ -19,9 +19,6 @@ PROJECT_PATH = "./"
|
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
-
def _define_columns(example):
|
| 23 |
-
text_splited = example["text"].split('\t')
|
| 24 |
-
return {"text": text_splited[1].strip(), "labels": int(text_splited[0])}
|
| 25 |
|
| 26 |
class Sentiment(datasets.GeneratorBasedBuilder):
|
| 27 |
'''Custom Dataset created using the HuggingFace api so we can
|
|
@@ -36,14 +33,18 @@ class Sentiment(datasets.GeneratorBasedBuilder):
|
|
| 36 |
),
|
| 37 |
supervised_keys=("text", "labels"),
|
| 38 |
)
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
def _split_generators(self, _):
|
| 41 |
"""Returns SplitGenerators."""
|
| 42 |
|
| 43 |
data_dir = "./"
|
| 44 |
|
| 45 |
data = load_dataset("text", data_files="./HF_data.txt")
|
| 46 |
-
data = data.map(_define_columns)
|
| 47 |
|
| 48 |
texts_dataset_clean = data["train"].train_test_split(train_size=0.95, seed=12345)
|
| 49 |
# Rename the default "test" split to "validation"
|
|
|
|
| 19 |
|
| 20 |
|
| 21 |
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
class Sentiment(datasets.GeneratorBasedBuilder):
|
| 24 |
'''Custom Dataset created using the HuggingFace api so we can
|
|
|
|
| 33 |
),
|
| 34 |
supervised_keys=("text", "labels"),
|
| 35 |
)
|
| 36 |
+
|
| 37 |
+
def _define_columns(self,example):
|
| 38 |
+
text_splited = example["text"].split('\t')
|
| 39 |
+
return {"text": text_splited[1].strip(), "labels": int(text_splited[0])}
|
| 40 |
+
|
| 41 |
def _split_generators(self, _):
|
| 42 |
"""Returns SplitGenerators."""
|
| 43 |
|
| 44 |
data_dir = "./"
|
| 45 |
|
| 46 |
data = load_dataset("text", data_files="./HF_data.txt")
|
| 47 |
+
data = data.map(self._define_columns)
|
| 48 |
|
| 49 |
texts_dataset_clean = data["train"].train_test_split(train_size=0.95, seed=12345)
|
| 50 |
# Rename the default "test" split to "validation"
|