File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -62,17 +62,18 @@ def __str__(self) -> str:
62
62
def _inject_full_text_ocr (self , raw_prediction : StringDict ) -> None :
63
63
pages = raw_prediction .get ("inference" , {}).get ("pages" , [])
64
64
65
+ # check for: empty, missing, or null
65
66
if (
66
67
not pages
67
- or "extras" not in pages [0 ]
68
- or "full_text_ocr" not in pages [0 ]["extras" ]
68
+ or not pages [0 ]. get ( "extras" , None )
69
+ or not pages [0 ]["extras" ]. get ( "full_text_ocr" , None )
69
70
):
70
71
return
71
72
72
73
full_text_content = "\n " .join (
73
74
page ["extras" ]["full_text_ocr" ]["content" ]
74
75
for page in pages
75
- if "extras" in page and "full_text_ocr" in page ["extras" ]
76
+ if page . get ( "extras" , None ) and page ["extras" ]. get ( "full_text_ocr" , None )
76
77
)
77
78
78
79
artificial_text_obj = {"content" : full_text_content }
You can’t perform that action at this time.
0 commit comments