Marcio Monteiro commited on
Commit
ac7b414
•
1 Parent(s): ce097d8

fix: configs

Browse files
.gitattributes CHANGED
@@ -60,3 +60,5 @@ data/all/test.csv filter=lfs diff=lfs merge=lfs -text
60
  data/all/train.csv filter=lfs diff=lfs merge=lfs -text
61
  data/top4/test.csv filter=lfs diff=lfs merge=lfs -text
62
  data/top4/train.csv filter=lfs diff=lfs merge=lfs -text
 
 
 
60
  data/all/train.csv filter=lfs diff=lfs merge=lfs -text
61
  data/top4/test.csv filter=lfs diff=lfs merge=lfs -text
62
  data/top4/train.csv filter=lfs diff=lfs merge=lfs -text
63
+ data/original.csv filter=lfs diff=lfs merge=lfs -text
64
+ data/top4-balanced.csv filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -4,12 +4,8 @@ language:
4
  task_categories:
5
  - text-classification
6
 
7
- configs:
8
  - config_name: original
9
- data_files:
10
- - split: complete
11
- path: "data/all/train.csv"
12
- default: true
13
  features:
14
  - name: source
15
  dtype: string
@@ -47,11 +43,10 @@ configs:
47
  '11': Top Stories
48
  '12': U.S.
49
  '13': World
50
-
 
 
51
  - config_name: top4-balanced
52
- data_files:
53
- - split: complete
54
- path: "data/top4-balanced/train.csv"
55
  features:
56
  - name: source
57
  dtype: string
@@ -89,3 +84,6 @@ configs:
89
  '11': Top Stories
90
  '12': U.S.
91
  '13': World
 
 
 
 
4
  task_categories:
5
  - text-classification
6
 
7
+ dataset_info:
8
  - config_name: original
 
 
 
 
9
  features:
10
  - name: source
11
  dtype: string
 
43
  '11': Top Stories
44
  '12': U.S.
45
  '13': World
46
+ splits:
47
+ - name: complete
48
+ path: "data/original.csv"
49
  - config_name: top4-balanced
 
 
 
50
  features:
51
  - name: source
52
  dtype: string
 
84
  '11': Top Stories
85
  '12': U.S.
86
  '13': World
87
+ splits:
88
+ - name: complete
89
+ path: "data/top4-balanced.csv"
convert.py CHANGED
@@ -27,7 +27,7 @@ HEADER = [
27
  "pubdate",
28
  ]
29
 
30
- OUTPUT_FILE_PATH = os.path.join("data", "all", "train.csv")
31
 
32
  def _clean_text(text):
33
  text = text.replace("\\\n", "\n")
@@ -52,14 +52,16 @@ def _clean_html(text):
52
  # remove extra spaces at the beginning of the text
53
  lines = [line.strip() for line in text.split("\n")]
54
 
55
- output = "\n".join(lines)
 
 
56
 
57
- output = output.strip()
58
-
59
- if output == "null":
60
- return ""
61
-
62
- return output
63
 
64
 
65
  def _clean_image(image):
@@ -130,7 +132,7 @@ def save_csv(rows, fname=OUTPUT_FILE_PATH):
130
  """
131
  Save the processed data into a CSV file.
132
  """
133
- os.makedirs(os.path.join("data", "all"), exist_ok=True)
134
 
135
  with open(fname, "w", encoding="utf8") as f:
136
  writer = csv.DictWriter(f, fieldnames=rows[0].keys())
@@ -161,9 +163,7 @@ def save_csv_categories(categories, config_name, is_balanced=True, **kwargs):
161
  else:
162
  df = df[df["category"].isin(categories)]
163
 
164
- os.makedirs(f"data/{config_name}", exist_ok=True)
165
-
166
- df.to_csv(os.path.join("data", config_name, "train.csv"), index=False)
167
 
168
 
169
  def save_categories(categories, fname="categories.txt"):
 
27
  "pubdate",
28
  ]
29
 
30
+ OUTPUT_FILE_PATH = os.path.join("data", "original.csv")
31
 
32
  def _clean_text(text):
33
  text = text.replace("\\\n", "\n")
 
52
  # remove extra spaces at the beginning of the text
53
  lines = [line.strip() for line in text.split("\n")]
54
 
55
+ if lines:
56
+ output = "\n".join(lines)
57
+ output = output.strip()
58
 
59
+ if output == "null":
60
+ return ""
61
+
62
+ return output
63
+
64
+ return ""
65
 
66
 
67
  def _clean_image(image):
 
132
  """
133
  Save the processed data into a CSV file.
134
  """
135
+ os.makedirs("data", exist_ok=True)
136
 
137
  with open(fname, "w", encoding="utf8") as f:
138
  writer = csv.DictWriter(f, fieldnames=rows[0].keys())
 
163
  else:
164
  df = df[df["category"].isin(categories)]
165
 
166
+ df.to_csv(os.path.join("data", f"{config_name}.csv"), index=False)
 
 
167
 
168
 
169
  def save_categories(categories, fname="categories.txt"):
data/{all/train.csv → original.csv} RENAMED
File without changes
data/{top4-balanced/train.csv → top4-balanced.csv} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:4a9a5712dd5bf47810bc6fc7df31b86a6eaba594cc34353efcf02fd7f6289771
3
- size 344070837
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d877f38b2e29c8cbf7d7334f846158c7eb7c463ad5e51827d41dfb54b3006dd2
3
+ size 343796732