amielle commited on
Commit
56d5835
1 Parent(s): 9b174bd

chore: Add individual error handling per summary type

Browse files
Files changed (1) hide show
  1. util/summarizer.py +13 -4
util/summarizer.py CHANGED
@@ -40,7 +40,11 @@ class PatentSummarizer():
40
  summaries.append(abstract_summary)
41
  else:
42
  summaries.append(None)
43
-
 
 
 
 
44
  if "Background" in summaries_generated and background is not None:
45
  background = background[0: textproc.get_word_index(background, word_limit)]
46
 
@@ -49,7 +53,11 @@ class PatentSummarizer():
49
  summaries.append(background_summary)
50
  else:
51
  summaries.append(None)
52
-
 
 
 
 
53
  if "Claims" in summaries_generated and claims is not None:
54
  if collate_claims:
55
  claims = ' '.join(claims)
@@ -65,7 +73,8 @@ class PatentSummarizer():
65
  summaries.append(claims_summary)
66
  else:
67
  summaries.append(None)
 
 
 
68
 
69
  return summaries
70
- except Exception as e:
71
- return [f'[ERROR] {e}'] + [None]*(len(summaries_generated) - 1)
 
40
  summaries.append(abstract_summary)
41
  else:
42
  summaries.append(None)
43
+ except Exception as e:
44
+ summaries.append(None)
45
+ print(f'[ERROR] {e}')
46
+
47
+ try:
48
  if "Background" in summaries_generated and background is not None:
49
  background = background[0: textproc.get_word_index(background, word_limit)]
50
 
 
53
  summaries.append(background_summary)
54
  else:
55
  summaries.append(None)
56
+ except Exception as e:
57
+ summaries.append(None)
58
+ print(f'[ERROR] {e}')
59
+
60
+ try:
61
  if "Claims" in summaries_generated and claims is not None:
62
  if collate_claims:
63
  claims = ' '.join(claims)
 
73
  summaries.append(claims_summary)
74
  else:
75
  summaries.append(None)
76
+ except Exception as e:
77
+ summaries.append(None)
78
+ print(f'[ERROR] {e}')
79
 
80
  return summaries