in function_app/src/result_enrichment/doc_intelligence.py [0:0]
def extract_di_words(di_result: AnalyzeResult) -> List[EnrichedDocumentWord]:
"""
Extract all words from a Document Intelligence response, enriching them.
:param raw_azure_doc_response:
The raw Document Intelligence response for a single document.
:return:
A list of all words in the document.
"""
di_words = list()
for page in di_result.pages:
for word in page.words:
out_word = EnrichedDocumentWord(
normalized_polygon=scale_flat_poly_list(
word.polygon,
existing_scale=(page.width, page.height),
new_scale=(1, 1),
),
page_number=page.page_number,
**word,
)
di_words.append(out_word)
return di_words