Commit
·
ef966b2
1
Parent(s):
2fd7cf9
test
Browse files- AmericanStories.py +18 -17
AmericanStories.py
CHANGED
|
@@ -175,20 +175,21 @@ class AmericanStories(datasets.GeneratorBasedBuilder):
|
|
| 175 |
for filepath in os.listdir(year_dir):
|
| 176 |
with open(os.path.join(year_dir,filepath), encoding="utf-8") as f:
|
| 177 |
data = json.load(f)
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
|
|
|
|
|
| 175 |
for filepath in os.listdir(year_dir):
|
| 176 |
with open(os.path.join(year_dir,filepath), encoding="utf-8") as f:
|
| 177 |
data = json.load(f)
|
| 178 |
+
if "lccn" in data.keys():
|
| 179 |
+
scan_id=filepath.split('.')[0]
|
| 180 |
+
scan_date=filepath.split("_")[0]
|
| 181 |
+
scan_page=filepath.split("_")[1]
|
| 182 |
+
scan_edition=filepath.split("_")[-2][8:]
|
| 183 |
+
newspaper_name=data["lccn"]["title"]
|
| 184 |
+
full_articles_in_data=data["full articles"]
|
| 185 |
+
for article in full_articles_in_data:
|
| 186 |
+
article_id=str(article["full_article_id"]) +"_" +scan_id
|
| 187 |
+
yield article_id, {
|
| 188 |
+
"newspaper_name": newspaper_name,
|
| 189 |
+
"edition": scan_edition,
|
| 190 |
+
"date": scan_date,
|
| 191 |
+
"page": scan_page,
|
| 192 |
+
"headline": article["headline"],
|
| 193 |
+
"byline": article["byline"],
|
| 194 |
+
"article": article["article"]
|
| 195 |
+
}
|