in function_app/src/helpers/content_understanding.py [0:0]
def simplify_cu_field_dict(field_info: dict) -> dict:
"""
Simplifies a Content Understanding field dictionary to keep only the field
values and confidence scores. Returns the result as a dictionary.
:param field_info: Content Understanding field information.
:type field_info: dict
:return: Simplified field dictionary.
:rtype: dict
"""
if field_info["type"] == "object":
return {
apply_md_text_formatting(k, True): simplify_cu_field_dict(v)
for k, v in field_info.get("valueObject", {}).items()
}
elif field_info["type"] == "array":
return [simplify_cu_field_dict(v) for v in field_info.get("valueArray", [])]
else:
field_name = get_cu_value_field_name(field_info)
return format_extracted_field_output(
field_info.get(field_name), field_info.get("confidence")
)