Update ccnews_split.py
Browse files- ccnews_split.py +7 -14
ccnews_split.py
CHANGED
@@ -141,26 +141,19 @@ class CCNews(datasets.GeneratorBasedBuilder):
|
|
141 |
article = json.load(f)
|
142 |
if level == "sentence":
|
143 |
full_article = article["maintext"].strip() if article["maintext"] is not None else ""
|
144 |
-
|
145 |
-
yield id_, {
|
146 |
-
"title": article["title"].strip() if article["title"] is not None else "",
|
147 |
-
"text": sent,
|
148 |
-
"domain": article["source_domain"].strip() if article["source_domain"] is not None else "",
|
149 |
-
"date": article["date_publish"].strip() if article["date_publish"] is not None else "",
|
150 |
-
"description": article["description"].strip() if article["description"] is not None else "",
|
151 |
-
"url": article["url"].strip() if article["url"] is not None else "",
|
152 |
-
"image_url": article["image_url"].strip() if article["image_url"] is not None else "",
|
153 |
-
}
|
154 |
-
id_ += 1
|
155 |
-
else:
|
156 |
-
yield id_, {
|
157 |
"title": article["title"].strip() if article["title"] is not None else "",
|
158 |
-
"text": article["maintext"].strip() if article["maintext"] is not None else "",
|
159 |
"domain": article["source_domain"].strip() if article["source_domain"] is not None else "",
|
160 |
"date": article["date_publish"].strip() if article["date_publish"] is not None else "",
|
161 |
"description": article["description"].strip() if article["description"] is not None else "",
|
162 |
"url": article["url"].strip() if article["url"] is not None else "",
|
163 |
"image_url": article["image_url"].strip() if article["image_url"] is not None else "",
|
164 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
id_ += 1
|
166 |
|
|
|
141 |
article = json.load(f)
|
142 |
if level == "sentence":
|
143 |
full_article = article["maintext"].strip() if article["maintext"] is not None else ""
|
144 |
+
doc_dict = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
"title": article["title"].strip() if article["title"] is not None else "",
|
|
|
146 |
"domain": article["source_domain"].strip() if article["source_domain"] is not None else "",
|
147 |
"date": article["date_publish"].strip() if article["date_publish"] is not None else "",
|
148 |
"description": article["description"].strip() if article["description"] is not None else "",
|
149 |
"url": article["url"].strip() if article["url"] is not None else "",
|
150 |
"image_url": article["image_url"].strip() if article["image_url"] is not None else "",
|
151 |
}
|
152 |
+
for sent in full_article.split("\n"):
|
153 |
+
doc_dict["text"] = sent
|
154 |
+
yield id_, doc_dict
|
155 |
+
id_ += 1
|
156 |
+
else:
|
157 |
+
yield id_,
|
158 |
id_ += 1
|
159 |
|