in cloud-run-jobs/process.py [0:0]
def document_info(document):
"""
Creates a Python dict with needed data from the processed document object.
"""
info = {"lines": []}
for entity in document.entities:
if entity.type_ == "line_item":
line = {}
for property in entity.properties:
line[property.type_] = property.mention_text
info["lines"].append(line)
else:
info[entity.type_] = entity.mention_text
return info