imbesat-rizvi
commited on
Commit
•
31cf874
1
Parent(s):
8f8eea5
Added processing to remove rows with empty text.
Browse files- newsgroups.py +3 -0
newsgroups.py
CHANGED
@@ -120,6 +120,9 @@ class Newsgroups(datasets.GeneratorBasedBuilder):
|
|
120 |
train_df["text"] = train_df["text"].str.replace("\s+", " ", regex=True)
|
121 |
test_df["text"] = test_df["text"].str.replace("\s+", " ", regex=True)
|
122 |
|
|
|
|
|
|
|
123 |
train_df, val_df = train_test_split(train_df, test_size=0.2, random_state=42, stratify=train_df["labels"])
|
124 |
train_df = train_df.reset_index(drop=True)
|
125 |
val_df = val_df.reset_index(drop=True)
|
|
|
120 |
train_df["text"] = train_df["text"].str.replace("\s+", " ", regex=True)
|
121 |
test_df["text"] = test_df["text"].str.replace("\s+", " ", regex=True)
|
122 |
|
123 |
+
train_df = train_df[train_df["text"].str.strip()!=""]
|
124 |
+
test_df = test_df[test_df["text"].str.strip()!=""]
|
125 |
+
|
126 |
train_df, val_df = train_test_split(train_df, test_size=0.2, random_state=42, stratify=train_df["labels"])
|
127 |
train_df = train_df.reset_index(drop=True)
|
128 |
val_df = val_df.reset_index(drop=True)
|