96abhishekarora commited on
Commit
ef966b2
·
1 Parent(s): 2fd7cf9
Files changed (1) hide show
  1. 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
- scan_id=filepath.split('.')[0]
179
- scan_date=filepath.split("_")[0]
180
- scan_page=filepath.split("_")[1]
181
- scan_edition=filepath.split("_")[-2][8:]
182
- newspaper_name=data["lccn"]["title"]
183
- full_articles_in_data=data["full articles"]
184
- for article in full_articles_in_data:
185
- article_id=str(article["full_article_id"]) +"_" +scan_id
186
- yield article_id, {
187
- "newspaper_name": newspaper_name,
188
- "edition": scan_edition,
189
- "date": scan_date,
190
- "page": scan_page,
191
- "headline": article["headline"],
192
- "byline": article["byline"],
193
- "article": article["article"]
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
+ }