tombryan commited on
Commit
17e5e42
1 Parent(s): 447c93d

avoiding null dbpedia problem

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -140,10 +140,13 @@ def query(sentence: str, state: str, years: List[str]) -> List[str]:
140
 
141
  doc = response.json()
142
  article = doc['bboxes'][int(doc['article_id'])]
143
-
 
 
 
144
  results = {
145
  'newspaper_name': doc['lccn']['title'],
146
- 'location': doc['lccn']['dbpedia_ids'][0].replace('%2C_', ', '),
147
  'date': doc['scan']['date'],
148
  'article_text': article['raw_text'],
149
  'pdf_link': doc['scan']['jp2_url'].replace('jp2', 'pdf')
 
140
 
141
  doc = response.json()
142
  article = doc['bboxes'][int(doc['article_id'])]
143
+ if len(article['lccn']['dpedia_ids']) == 0:
144
+ location = 'Unknown'
145
+ else:
146
+ location = article['lccn']['dpedia_ids'][0].replace('%2C_', ', ')
147
  results = {
148
  'newspaper_name': doc['lccn']['title'],
149
+ 'location': location,
150
  'date': doc['scan']['date'],
151
  'article_text': article['raw_text'],
152
  'pdf_link': doc['scan']['jp2_url'].replace('jp2', 'pdf')