Thank you for using the Microsoft Q&A forum.
It seems that you are trying to use Azure Document intelligence to analyze a contract document. Unfortunately, I couldn't find any documentation containing the wrapper code for the pre-built contract model. However, you can use the Azure DI SDK for Python to analyze the contract document. The SDK provides a begin_recognize_content
method that can be used to extract text and layout information from the contract document. You can find information about the SDK/ REST API and its usage in the Azure documentation.
Here's a sample repro code snippet, that I tried to analyze the contract document:
from azure.ai.formrecognizer import FormRecognizerClient
from azure.core.credentials import AzureKeyCredential
endpoint = "YOUR_ENDPOINT"
key = "YOUR_KEY"
def analyze_contract():
try:
form_recognizer_client = FormRecognizerClient(endpoint, AzureKeyCredential(key))
with open("YOUR_PATH_TO_CONTRACT_FILE", "rb") as f:
poller = form_recognizer_client.begin_recognize_content(form=f)
result = poller.result()
if not isinstance(result, list):
print("Unexpected result format. Expected a list.")
else:
for page_idx, page in enumerate(result):
print("Page #{}:".format(page_idx))
for attr_name in dir(page):
if not attr_name.startswith("__"):
attr_value = getattr(page, attr_name)
print("Attribute: {}, Value: {}".format(attr_name, attr_value))
except Exception as e:
print("An error occurred:", e)
# Call the function to analyze the contract
analyze_contract()
Please modify the code as per your use-case.
Output:
For more details, please refer this github repo.
I hope you understand. Thank you.
If this answers your query, do click Accept Answer
and Yes
for was this answer helpful.