다음을 통해 공유


FormRecognizerClient 클래스

FormRecognizerClient는 양식 및 이미지의 정보를 구조화된 데이터로 추출합니다. 미리 빌드된 모델(영수증, 명함, 청구서, ID 문서)을 사용하여 분석하고, 양식의 콘텐츠/레이아웃을 인식하고, 학습된 모델에서 사용자 지정 양식을 분석하는 데 사용할 인터페이스입니다. URL의 입력과 스트림의 입력에 따라 다른 메서드를 제공합니다.

참고

FormRecognizerClient는 API 버전 <=v2.1과 함께 사용해야 합니다.

API 버전 2022-08-31을 사용하려면 DocumentAnalysisClient를 인스턴스화합니다.

상속
azure.ai.formrecognizer._form_base_client.FormRecognizerClientBase
FormRecognizerClient

생성자

FormRecognizerClient(endpoint: str, credential: AzureKeyCredential | TokenCredential, **kwargs: Any)

매개 변수

endpoint
str
필수

지원되는 Cognitive Services 엔드포인트(프로토콜 및 호스트 이름( 예: https://westus2.api.cognitive.microsoft.com).

credential
AzureKeyCredential 또는 TokenCredential
필수

클라이언트가 Azure에 연결하는 데 필요한 자격 증명입니다. API 키 또는 의 토큰 자격 증명identity을 사용하는 경우 AzureKeyCredential의 instance.

api_version
str 또는 FormRecognizerApiVersion

요청에 사용할 서비스의 API 버전입니다. 기본값은 API 버전 v2.1입니다. 이전 버전으로 설정하면 기능 호환성이 저하될 수 있습니다. 지원되는 최신 API 버전 및 기능을 사용하려면 DocumentAnalysisClient를 대신 인스턴스화합니다.

예제

엔드포인트 및 API 키를 사용하여 FormRecognizerClient를 만듭니다.


   from azure.core.credentials import AzureKeyCredential
   from azure.ai.formrecognizer import FormRecognizerClient
   endpoint = os.environ["AZURE_FORM_RECOGNIZER_ENDPOINT"]
   key = os.environ["AZURE_FORM_RECOGNIZER_KEY"]

   form_recognizer_client = FormRecognizerClient(endpoint, AzureKeyCredential(key))

토큰 자격 증명을 사용하여 FormRecognizerClient를 만듭니다.


   """DefaultAzureCredential will use the values from these environment
   variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET
   """
   from azure.ai.formrecognizer import FormRecognizerClient
   from azure.identity import DefaultAzureCredential

   endpoint = os.environ["AZURE_FORM_RECOGNIZER_ENDPOINT"]
   credential = DefaultAzureCredential()

   form_recognizer_client = FormRecognizerClient(endpoint, credential)

메서드

begin_recognize_business_cards

지정된 비즈니스 카드 필드 텍스트 및 의미 체계 값을 추출합니다. 입력 문서는 지원되는 콘텐츠 형식 중 하나여야 합니다. 'application/pdf', 'image/jpeg', 'image/png', 'image/tiff' 또는 'image/bmp'.

비즈니스 카드 찾은 필드를 참조하세요.https://aka.ms/formrecognizer/businesscardfields

버전 v2.1의 새로운 기능: begin_recognize_business_cards 클라이언트 메서드

begin_recognize_business_cards_from_url

지정된 비즈니스 카드 필드 텍스트 및 의미 체계 값을 추출합니다. 입력 문서는 분석할 카드 위치(URL)여야 합니다.

비즈니스 카드 찾은 필드를 참조하세요.https://aka.ms/formrecognizer/businesscardfields

버전 v2.1의 새로운 기능: begin_recognize_business_cards_from_url 클라이언트 메서드

begin_recognize_content

지정된 문서에서 텍스트 및 콘텐츠/레이아웃 정보를 추출합니다. 입력 문서는 지원되는 콘텐츠 형식 중 하나여야 합니다. 'application/pdf', 'image/jpeg', 'image/png', 'image/tiff' 또는 'image/bmp'.

버전 v2.1의 새로운 기능: 페이지, 언어reading_order 키워드(keyword) 인수 및 이미지/bmp 콘텐츠 지원

begin_recognize_content_from_url

지정된 문서에서 텍스트 및 레이아웃 정보를 추출합니다. 입력 문서는 분석할 문서의 위치(URL)여야 합니다.

버전 v2.1의 새로운 기능: 페이지, 언어reading_order 키워드(keyword) 인수 및 이미지/bmp 콘텐츠 지원

begin_recognize_custom_forms

레이블을 사용하거나 사용하지 않고 학습된 모델을 사용하여 사용자 지정 양식을 분석합니다. 분석할 양식은 모델을 학습시키는 데 사용된 양식과 동일한 형식이어야 합니다. 입력 문서는 지원되는 콘텐츠 형식 중 하나여야 합니다. 'application/pdf', 'image/jpeg', 'image/png', 'image/tiff' 또는 'image/bmp'.

begin_recognize_custom_forms_from_url

레이블을 사용하거나 사용하지 않고 학습된 모델을 사용하여 사용자 지정 양식을 분석합니다. 분석할 양식은 모델을 학습시키는 데 사용된 양식과 동일한 형식이어야 합니다. 입력 문서는 분석할 문서의 위치(URL)여야 합니다.

begin_recognize_identity_documents

지정된 ID 문서에서 필드 텍스트 및 의미 체계 값을 추출합니다. 입력 문서는 지원되는 콘텐츠 형식 중 하나여야 합니다( 'application/pdf', 'image/jpeg', 'image/png', 'image/tiff' 또는 'image/bmp').

ID 문서에서 찾은 필드를 참조하세요. https://aka.ms/formrecognizer/iddocumentfields

버전 v2.1의 새로운 기능: begin_recognize_identity_documents 클라이언트 메서드

begin_recognize_identity_documents_from_url

지정된 ID 문서에서 필드 텍스트 및 의미 체계 값을 추출합니다. 입력 문서는 분석할 ID 문서의 위치(URL)여야 합니다.

ID 문서에서 찾은 필드를 참조하세요. https://aka.ms/formrecognizer/iddocumentfields

버전 v2.1의 새로운 기능: begin_recognize_identity_documents_from_url 클라이언트 메서드

begin_recognize_invoices

지정된 청구서에서 필드 텍스트 및 의미 체계 값을 추출합니다. 입력 문서는 지원되는 콘텐츠 형식 중 하나여야 합니다( 'application/pdf', 'image/jpeg', 'image/png', 'image/tiff' 또는 'image/bmp').

청구서에 있는 필드를 참조하세요. https://aka.ms/formrecognizer/invoicefields

버전 v2.1의 새로운 기능: begin_recognize_invoices 클라이언트 메서드

begin_recognize_invoices_from_url

지정된 청구서에서 필드 텍스트 및 의미 체계 값을 추출합니다. 입력 문서는 분석할 청구서의 위치(URL)여야 합니다.

여기에서 청구서 카드 찾은 필드를 참조하세요.https://aka.ms/formrecognizer/invoicefields

버전 v2.1의 새로운 기능: begin_recognize_invoices_from_url 클라이언트 메서드

begin_recognize_receipts

지정된 판매 영수증에서 필드 텍스트 및 의미 체계 값을 추출합니다. 입력 문서는 지원되는 콘텐츠 형식 중 하나여야 합니다( 'application/pdf', 'image/jpeg', 'image/png', 'image/tiff' 또는 'image/bmp').

영수증에서 찾은 필드를 참조하세요. https://aka.ms/formrecognizer/receiptfields

버전 v2.1의 새로운 기능: 이미지/bmp 콘텐츠에 대한 인수 및 지원을 키워드(keyword) 로캘페이지

begin_recognize_receipts_from_url

지정된 판매 영수증에서 필드 텍스트 및 의미 체계 값을 추출합니다. 입력 문서는 분석할 영수증의 위치(URL)여야 합니다.

영수증에서 찾은 필드를 참조하세요. https://aka.ms/formrecognizer/receiptfields

버전 v2.1의 새로운 기능: 이미지/bmp 콘텐츠에 대한 인수 및 지원을 키워드(keyword) 로캘페이지

close

세션을 닫습니다 FormRecognizerClient .

send_request

클라이언트의 기존 파이프라인을 사용하여 네트워크 요청을 실행합니다.

요청 URL은 기본 URL을 기준으로 할 수 있습니다. 요청에 사용되는 서비스 API 버전은 달리 지정하지 않는 한 클라이언트의 버전과 동일합니다. 상대 URL에서 클라이언트의 구성된 API 버전을 재정의하는 것은 API 버전 2022-08-31 이상을 사용하는 클라이언트에서 지원됩니다. 모든 API 버전으로 클라이언트에서 지원되는 절대 URL의 재정의. 응답이 오류인 경우 이 메서드는 발생하지 않습니다. 예외를 발생하려면 반환된 응답 개체에서 raise_for_status() 를 호출합니다. 이 메서드를 사용하여 사용자 지정 요청을 보내는 방법에 대한 자세한 내용은 을 참조하세요 https://aka.ms/azsdk/dpcodegen/python/send_request.

begin_recognize_business_cards

지정된 비즈니스 카드 필드 텍스트 및 의미 체계 값을 추출합니다. 입력 문서는 지원되는 콘텐츠 형식 중 하나여야 합니다. 'application/pdf', 'image/jpeg', 'image/png', 'image/tiff' 또는 'image/bmp'.

비즈니스 카드 찾은 필드를 참조하세요.https://aka.ms/formrecognizer/businesscardfields

버전 v2.1의 새로운 기능: begin_recognize_business_cards 클라이언트 메서드

begin_recognize_business_cards(business_card: bytes | IO[bytes], **kwargs: Any) -> LROPoller[List[RecognizedForm]]

매개 변수

business_card
bytes 또는 IO[bytes]
필수

JPEG, PNG, PDF, TIFF 또는 BMP 형식 파일 스트림 또는 바이트.

locale
str

비즈니스 카드 로캘입니다. 지원되는 로캘에는 en-US, en-AU, en-CA, en-GB 및 en-IN이 포함됩니다.

include_field_elements
bool

각 양식 필드의 선, 단어 및 선택 표시와 같은 페이지 및 필드 요소당 모든 줄을 포함할지 여부입니다.

pages
list[str]

다중 페이지 문서에 대한 사용자 지정 페이지 번호(PDF/TIFF). 결과에서 가져올 페이지 번호 및/또는 페이지 범위를 입력합니다. 페이지 범위의 경우 pages=["1-3", "5-6"]와 같은 하이픈을 사용합니다. 각 페이지 번호 또는 범위를 쉼표로 구분합니다.

content_type
str 또는 FormContentType

API로 전송된 본문의 콘텐츠 형식입니다. 콘텐츠 형식은 자동 검색되지만 이 키워드(keyword) 인수를 전달하여 재정의할 수 있습니다. 옵션은 을 참조하세요 FormContentType.

continuation_token
str

저장된 상태에서 폴러를 다시 시작하는 연속 토큰입니다.

반환

LROPoller의 instance. poller 개체에서 result() 를 호출하여 목록[RecognizedForm]을 반환합니다.

반환 형식

예외

예제

파일에서 명함을 인식합니다.


   from azure.core.credentials import AzureKeyCredential
   from azure.ai.formrecognizer import FormRecognizerClient

   endpoint = os.environ["AZURE_FORM_RECOGNIZER_ENDPOINT"]
   key = os.environ["AZURE_FORM_RECOGNIZER_KEY"]

   form_recognizer_client = FormRecognizerClient(
       endpoint=endpoint, credential=AzureKeyCredential(key)
   )
   with open(path_to_sample_forms, "rb") as f:
       poller = form_recognizer_client.begin_recognize_business_cards(business_card=f, locale="en-US")
   business_cards = poller.result()

   for idx, business_card in enumerate(business_cards):
       print("--------Recognizing business card #{}--------".format(idx+1))
       contact_names = business_card.fields.get("ContactNames")
       if contact_names:
           for contact_name in contact_names.value:
               print("Contact First Name: {} has confidence: {}".format(
                   contact_name.value["FirstName"].value, contact_name.value["FirstName"].confidence
               ))
               print("Contact Last Name: {} has confidence: {}".format(
                   contact_name.value["LastName"].value, contact_name.value["LastName"].confidence
               ))
       company_names = business_card.fields.get("CompanyNames")
       if company_names:
           for company_name in company_names.value:
               print("Company Name: {} has confidence: {}".format(company_name.value, company_name.confidence))
       departments = business_card.fields.get("Departments")
       if departments:
           for department in departments.value:
               print("Department: {} has confidence: {}".format(department.value, department.confidence))
       job_titles = business_card.fields.get("JobTitles")
       if job_titles:
           for job_title in job_titles.value:
               print("Job Title: {} has confidence: {}".format(job_title.value, job_title.confidence))
       emails = business_card.fields.get("Emails")
       if emails:
           for email in emails.value:
               print("Email: {} has confidence: {}".format(email.value, email.confidence))
       websites = business_card.fields.get("Websites")
       if websites:
           for website in websites.value:
               print("Website: {} has confidence: {}".format(website.value, website.confidence))
       addresses = business_card.fields.get("Addresses")
       if addresses:
           for address in addresses.value:
               print("Address: {} has confidence: {}".format(address.value, address.confidence))
       mobile_phones = business_card.fields.get("MobilePhones")
       if mobile_phones:
           for phone in mobile_phones.value:
               print("Mobile phone number: {} has confidence: {}".format(phone.value, phone.confidence))
       faxes = business_card.fields.get("Faxes")
       if faxes:
           for fax in faxes.value:
               print("Fax number: {} has confidence: {}".format(fax.value, fax.confidence))
       work_phones = business_card.fields.get("WorkPhones")
       if work_phones:
           for work_phone in work_phones.value:
               print("Work phone number: {} has confidence: {}".format(work_phone.value, work_phone.confidence))
       other_phones = business_card.fields.get("OtherPhones")
       if other_phones:
           for other_phone in other_phones.value:
               print("Other phone number: {} has confidence: {}".format(other_phone.value, other_phone.confidence))

begin_recognize_business_cards_from_url

지정된 비즈니스 카드 필드 텍스트 및 의미 체계 값을 추출합니다. 입력 문서는 분석할 카드 위치(URL)여야 합니다.

비즈니스 카드 찾은 필드를 참조하세요.https://aka.ms/formrecognizer/businesscardfields

버전 v2.1의 새로운 기능: begin_recognize_business_cards_from_url 클라이언트 메서드

begin_recognize_business_cards_from_url(business_card_url: str, **kwargs: Any) -> LROPoller[List[RecognizedForm]]

매개 변수

business_card_url
str
필수

분석할 비즈니스 카드 URL입니다. 입력은 지원되는 형식 중 하나인 JPEG, PNG, PDF, TIFF 또는 BMP의 유효한 인코딩된 URL이어야 합니다.

locale
str

비즈니스 카드 로캘입니다. 지원되는 로캘에는 en-US, en-AU, en-CA, en-GB 및 en-IN이 포함됩니다.

include_field_elements
bool

각 양식 필드의 선, 단어 및 선택 표시와 같은 페이지 및 필드 요소당 모든 줄을 포함할지 여부입니다.

pages
list[str]

다중 페이지 문서에 대한 사용자 지정 페이지 번호(PDF/TIFF). 결과에서 가져올 페이지 번호 및/또는 페이지 범위를 입력합니다. 페이지 범위의 경우 pages=["1-3", "5-6"]와 같은 하이픈을 사용합니다. 각 페이지 번호 또는 범위를 쉼표로 구분합니다.

continuation_token
str

저장된 상태에서 폴러를 다시 시작하는 연속 토큰입니다.

반환

LROPoller의 instance. poller 개체에서 result() 를 호출하여 목록[RecognizedForm]을 반환합니다.

반환 형식

예외

begin_recognize_content

지정된 문서에서 텍스트 및 콘텐츠/레이아웃 정보를 추출합니다. 입력 문서는 지원되는 콘텐츠 형식 중 하나여야 합니다. 'application/pdf', 'image/jpeg', 'image/png', 'image/tiff' 또는 'image/bmp'.

버전 v2.1의 새로운 기능: 페이지, 언어reading_order 키워드(keyword) 인수 및 이미지/bmp 콘텐츠 지원

begin_recognize_content(form: bytes | IO[bytes], **kwargs: Any) -> LROPoller[List[FormPage]]

매개 변수

form
bytes 또는 IO[bytes]
필수

JPEG, PNG, PDF, TIFF 또는 BMP 형식 파일 스트림 또는 바이트.

pages
list[str]

다중 페이지 문서에 대한 사용자 지정 페이지 번호(PDF/TIFF). 결과에서 가져올 페이지 번호 및/또는 페이지 범위를 입력합니다. 페이지 범위의 경우 pages=["1-3", "5-6"]와 같은 하이픈을 사용합니다. 각 페이지 번호 또는 범위를 쉼표로 구분합니다.

language
str

문서에 있는 텍스트의 BCP-47 언어 코드입니다. 지원되는 언어 코드는 를 참조하세요 https://docs.microsoft.com/azure/cognitive-services/form-recognizer/language-support. 콘텐츠는 자동 언어 식별 및 다국어 문서를 지원하므로 문서를 특정 언어로 강제로 처리하려는 경우에만 언어 코드를 제공합니다.

reading_order
str

반환된 텍스트 줄을 정렬하는 읽기 순서 알고리즘입니다. 지원되는 읽기 순서에는 기본(기본값), 자연이 포함됩니다. 'basic'을 설정하여 왼쪽에서 오른쪽으로, 위에서 아래로 선을 정렬합니다. 경우에 따라 근접이 더 높은 우선 순위로 처리됩니다. 위치 정보를 사용하여 주변 선을 함께 유지하여 줄을 정렬하도록 'natural'을 설정합니다.

content_type
str 또는 FormContentType

API로 전송된 본문의 콘텐츠 형식입니다. 콘텐츠 형식은 자동 검색되지만 이 키워드(keyword) 인수를 전달하여 재정의할 수 있습니다. 옵션은 을 참조하세요 FormContentType.

continuation_token
str

저장된 상태에서 폴러를 다시 시작하는 연속 토큰입니다.

반환

LROPoller의 instance. poller 개체에서 result() 를 호출하여 목록[FormPage]을 반환합니다.

반환 형식

예외

예제

양식에서 텍스트 및 콘텐츠/레이아웃 정보를 인식합니다.


   from azure.core.credentials import AzureKeyCredential
   from azure.ai.formrecognizer import FormRecognizerClient

   endpoint = os.environ["AZURE_FORM_RECOGNIZER_ENDPOINT"]
   key = os.environ["AZURE_FORM_RECOGNIZER_KEY"]

   form_recognizer_client = FormRecognizerClient(endpoint=endpoint, credential=AzureKeyCredential(key))
   with open(path_to_sample_forms, "rb") as f:
       poller = form_recognizer_client.begin_recognize_content(form=f)
   form_pages = poller.result()

   for idx, content in enumerate(form_pages):
       print("----Recognizing content from page #{}----".format(idx+1))
       print("Page has width: {} and height: {}, measured with unit: {}".format(
           content.width,
           content.height,
           content.unit
       ))
       for table_idx, table in enumerate(content.tables):
           print("Table # {} has {} rows and {} columns".format(table_idx, table.row_count, table.column_count))
           print("Table # {} location on page: {}".format(table_idx, format_bounding_box(table.bounding_box)))
           for cell in table.cells:
               print("...Cell[{}][{}] has text '{}' within bounding box '{}'".format(
                   cell.row_index,
                   cell.column_index,
                   cell.text,
                   format_bounding_box(cell.bounding_box)
               ))

       for line_idx, line in enumerate(content.lines):
           print("Line # {} has word count '{}' and text '{}' within bounding box '{}'".format(
               line_idx,
               len(line.words),
               line.text,
               format_bounding_box(line.bounding_box)
           ))
           if line.appearance:
               if line.appearance.style_name == "handwriting" and line.appearance.style_confidence > 0.8:
                   print("Text line '{}' is handwritten and might be a signature.".format(line.text))
           for word in line.words:
               print("...Word '{}' has a confidence of {}".format(word.text, word.confidence))

       for selection_mark in content.selection_marks:
           print("Selection mark is '{}' within bounding box '{}' and has a confidence of {}".format(
               selection_mark.state,
               format_bounding_box(selection_mark.bounding_box),
               selection_mark.confidence
           ))
       print("----------------------------------------")


begin_recognize_content_from_url

지정된 문서에서 텍스트 및 레이아웃 정보를 추출합니다. 입력 문서는 분석할 문서의 위치(URL)여야 합니다.

버전 v2.1의 새로운 기능: 페이지, 언어reading_order 키워드(keyword) 인수 및 이미지/bmp 콘텐츠 지원

begin_recognize_content_from_url(form_url: str, **kwargs: Any) -> LROPoller[List[FormPage]]

매개 변수

form_url
str
필수

분석할 양식의 URL입니다. 입력은 지원되는 형식 중 하나인 JPEG, PNG, PDF, TIFF 또는 BMP의 유효한 인코딩된 URL이어야 합니다.

pages
list[str]

다중 페이지 문서에 대한 사용자 지정 페이지 번호(PDF/TIFF). 결과에서 가져올 페이지 번호 및/또는 페이지 범위를 입력합니다. 페이지 범위의 경우 pages=["1-3", "5-6"]와 같은 하이픈을 사용합니다. 각 페이지 번호 또는 범위를 쉼표로 구분합니다.

language
str

문서에 있는 텍스트의 BCP-47 언어 코드입니다. 지원되는 언어 코드는 를 참조하세요 https://docs.microsoft.com/azure/cognitive-services/form-recognizer/language-support. 콘텐츠는 자동 언어 식별 및 다국어 문서를 지원하므로 문서를 특정 언어로 강제로 처리하려는 경우에만 언어 코드를 제공합니다.

reading_order
str

반환된 텍스트 줄을 정렬하는 읽기 순서 알고리즘입니다. 지원되는 읽기 순서에는 기본(기본값), 자연이 포함됩니다. 'basic'을 설정하여 왼쪽에서 오른쪽으로, 위에서 아래로 선을 정렬합니다. 경우에 따라 근접이 더 높은 우선 순위로 처리됩니다. 위치 정보를 사용하여 주변 선을 함께 유지하여 줄을 정렬하도록 'natural'을 설정합니다.

continuation_token
str

저장된 상태에서 폴러를 다시 시작하는 연속 토큰입니다.

반환

LROPoller의 instance. poller 개체에서 result() 를 호출하여 목록[FormPage]을 반환합니다.

반환 형식

예외

begin_recognize_custom_forms

레이블을 사용하거나 사용하지 않고 학습된 모델을 사용하여 사용자 지정 양식을 분석합니다. 분석할 양식은 모델을 학습시키는 데 사용된 양식과 동일한 형식이어야 합니다. 입력 문서는 지원되는 콘텐츠 형식 중 하나여야 합니다. 'application/pdf', 'image/jpeg', 'image/png', 'image/tiff' 또는 'image/bmp'.

begin_recognize_custom_forms(model_id: str, form: bytes | IO[bytes], **kwargs: Any) -> LROPoller[List[RecognizedForm]]

매개 변수

model_id
str
필수

사용자 지정 모델 식별자입니다.

form
bytes 또는 IO[bytes]
필수

JPEG, PNG, PDF, TIFF 또는 BMP 형식 파일 스트림 또는 바이트.

include_field_elements
bool

페이지당 모든 줄과 각 양식 필드의 선, 단어 및 선택 표시와 같은 필드 요소를 포함할지 여부입니다.

content_type
str 또는 FormContentType

API로 전송된 본문의 콘텐츠 형식입니다. 콘텐츠 형식은 자동 검색되지만 이 키워드(keyword) 인수를 전달하여 재정의할 수 있습니다. 옵션은 를 참조하세요 FormContentType.

pages
list[str]

다중 페이지 문서에 대한 사용자 지정 페이지 번호(PDF/TIFF). 결과에서 가져올 페이지 번호 및/또는 페이지 범위를 입력합니다. 페이지 범위의 경우 pages=["1-3", "5-6"]와 같은 하이픈을 사용합니다. 각 페이지 번호 또는 범위를 쉼표로 구분합니다.

continuation_token
str

저장된 상태에서 폴러를 다시 시작하는 연속 토큰입니다.

반환

LROPoller의 instance. poller 개체에서 result() 를 호출하여 목록[RecognizedForm]을 반환합니다.

반환 형식

예외

예제

사용자 지정 양식에서 필드 및 값을 인식합니다.


   from azure.core.credentials import AzureKeyCredential
   from azure.ai.formrecognizer import FormRecognizerClient

   endpoint = os.environ["AZURE_FORM_RECOGNIZER_ENDPOINT"]
   key = os.environ["AZURE_FORM_RECOGNIZER_KEY"]
   model_id = os.getenv("CUSTOM_TRAINED_MODEL_ID", custom_model_id)

   form_recognizer_client = FormRecognizerClient(
       endpoint=endpoint, credential=AzureKeyCredential(key)
   )

   # Make sure your form's type is included in the list of form types the custom model can recognize
   with open(path_to_sample_forms, "rb") as f:
       poller = form_recognizer_client.begin_recognize_custom_forms(
           model_id=model_id, form=f, include_field_elements=True
       )
   forms = poller.result()

   for idx, form in enumerate(forms):
       print("--------Recognizing Form #{}--------".format(idx+1))
       print("Form has type {}".format(form.form_type))
       print("Form has form type confidence {}".format(form.form_type_confidence))
       print("Form was analyzed with model with ID {}".format(form.model_id))
       for name, field in form.fields.items():
           # each field is of type FormField
           # label_data is populated if you are using a model trained without labels,
           # since the service needs to make predictions for labels if not explicitly given to it.
           if field.label_data:
               print("...Field '{}' has label '{}' with a confidence score of {}".format(
                   name,
                   field.label_data.text,
                   field.confidence
               ))

           print("...Label '{}' has value '{}' with a confidence score of {}".format(
               field.label_data.text if field.label_data else name, field.value, field.confidence
           ))

       # iterate over tables, lines, and selection marks on each page
       for page in form.pages:
           for i, table in enumerate(page.tables):
               print("\nTable {} on page {}".format(i+1, table.page_number))
               for cell in table.cells:
                   print("...Cell[{}][{}] has text '{}' with confidence {}".format(
                       cell.row_index, cell.column_index, cell.text, cell.confidence
                   ))
           print("\nLines found on page {}".format(page.page_number))
           for line in page.lines:
               print("...Line '{}' is made up of the following words: ".format(line.text))
               for word in line.words:
                   print("......Word '{}' has a confidence of {}".format(
                       word.text,
                       word.confidence
                   ))
           if page.selection_marks:
               print("\nSelection marks found on page {}".format(page.page_number))
               for selection_mark in page.selection_marks:
                   print("......Selection mark is '{}' and has a confidence of {}".format(
                       selection_mark.state,
                       selection_mark.confidence
                   ))

       print("-----------------------------------")

begin_recognize_custom_forms_from_url

레이블을 사용하거나 사용하지 않고 학습된 모델을 사용하여 사용자 지정 양식을 분석합니다. 분석할 양식은 모델을 학습시키는 데 사용된 양식과 동일한 형식이어야 합니다. 입력 문서는 분석할 문서의 위치(URL)여야 합니다.

begin_recognize_custom_forms_from_url(model_id: str, form_url: str, **kwargs: Any) -> LROPoller[List[RecognizedForm]]

매개 변수

model_id
str
필수

사용자 지정 모델 식별자입니다.

form_url
str
필수

분석할 양식의 URL입니다. 입력은 지원되는 형식 중 하나인 JPEG, PNG, PDF, TIFF 또는 BMP의 유효한 인코딩된 URL이어야 합니다.

include_field_elements
bool

페이지당 모든 줄과 각 양식 필드의 선, 단어 및 선택 표시와 같은 필드 요소를 포함할지 여부입니다.

pages
list[str]

다중 페이지 문서에 대한 사용자 지정 페이지 번호(PDF/TIFF). 결과에서 가져올 페이지 번호 및/또는 페이지 범위를 입력합니다. 페이지 범위의 경우 pages=["1-3", "5-6"]와 같은 하이픈을 사용합니다. 각 페이지 번호 또는 범위를 쉼표로 구분합니다.

continuation_token
str

저장된 상태에서 폴러를 다시 시작하는 연속 토큰입니다.

반환

LROPoller의 instance. poller 개체에서 result() 를 호출하여 목록[RecognizedForm]을 반환합니다.

반환 형식

예외

begin_recognize_identity_documents

지정된 ID 문서에서 필드 텍스트 및 의미 체계 값을 추출합니다. 입력 문서는 지원되는 콘텐츠 형식 중 하나여야 합니다( 'application/pdf', 'image/jpeg', 'image/png', 'image/tiff' 또는 'image/bmp').

ID 문서에서 찾은 필드를 참조하세요. https://aka.ms/formrecognizer/iddocumentfields

버전 v2.1의 새로운 기능: begin_recognize_identity_documents 클라이언트 메서드

begin_recognize_identity_documents(identity_document: bytes | IO[bytes], **kwargs: Any) -> LROPoller[List[RecognizedForm]]

매개 변수

identity_document
bytes 또는 IO[bytes]
필수

JPEG, PNG, PDF, TIFF 또는 BMP 형식 파일 스트림 또는 바이트.

include_field_elements
bool

페이지당 모든 줄과 각 양식 필드의 선, 단어 및 선택 표시와 같은 필드 요소를 포함할지 여부입니다.

content_type
str 또는 FormContentType

API로 전송된 본문의 콘텐츠 형식입니다. 콘텐츠 형식은 자동 검색되지만 이 키워드(keyword) 인수를 전달하여 재정의할 수 있습니다. 옵션은 를 참조하세요 FormContentType.

continuation_token
str

저장된 상태에서 폴러를 다시 시작하는 연속 토큰입니다.

pages
list[str]

다중 페이지 문서에 대한 사용자 지정 페이지 번호(PDF/TIFF). 결과에서 가져올 페이지 번호 및/또는 페이지 범위를 입력합니다. 페이지 범위의 경우 pages=["1-3", "5-6"]와 같은 하이픈을 사용합니다. 각 페이지 번호 또는 범위를 쉼표로 구분합니다.

반환

LROPoller의 instance. poller 개체에서 result() 를 호출하여 목록[RecognizedForm]을 반환합니다.

반환 형식

예외

예제

ID 문서 필드 인식


   from azure.core.credentials import AzureKeyCredential
   from azure.ai.formrecognizer import FormRecognizerClient

   endpoint = os.environ["AZURE_FORM_RECOGNIZER_ENDPOINT"]
   key = os.environ["AZURE_FORM_RECOGNIZER_KEY"]

   form_recognizer_client = FormRecognizerClient(
       endpoint=endpoint, credential=AzureKeyCredential(key)
   )
   with open(path_to_sample_forms, "rb") as f:
       poller = form_recognizer_client.begin_recognize_identity_documents(identity_document=f)
   id_documents = poller.result()

   for idx, id_document in enumerate(id_documents):
       print("--------Recognizing ID document #{}--------".format(idx+1))
       first_name = id_document.fields.get("FirstName")
       if first_name:
           print("First Name: {} has confidence: {}".format(first_name.value, first_name.confidence))
       last_name = id_document.fields.get("LastName")
       if last_name:
           print("Last Name: {} has confidence: {}".format(last_name.value, last_name.confidence))
       document_number = id_document.fields.get("DocumentNumber")
       if document_number:
           print("Document Number: {} has confidence: {}".format(document_number.value, document_number.confidence))
       dob = id_document.fields.get("DateOfBirth")
       if dob:
           print("Date of Birth: {} has confidence: {}".format(dob.value, dob.confidence))
       doe = id_document.fields.get("DateOfExpiration")
       if doe:
           print("Date of Expiration: {} has confidence: {}".format(doe.value, doe.confidence))
       sex = id_document.fields.get("Sex")
       if sex:
           print("Sex: {} has confidence: {}".format(sex.value, sex.confidence))
       address = id_document.fields.get("Address")
       if address:
           print("Address: {} has confidence: {}".format(address.value, address.confidence))
       country_region = id_document.fields.get("CountryRegion")
       if country_region:
           print("Country/Region: {} has confidence: {}".format(country_region.value, country_region.confidence))
       region = id_document.fields.get("Region")
       if region:
           print("Region: {} has confidence: {}".format(region.value, region.confidence))

begin_recognize_identity_documents_from_url

지정된 ID 문서에서 필드 텍스트 및 의미 체계 값을 추출합니다. 입력 문서는 분석할 ID 문서의 위치(URL)여야 합니다.

ID 문서에서 찾은 필드를 참조하세요. https://aka.ms/formrecognizer/iddocumentfields

버전 v2.1의 새로운 기능: begin_recognize_identity_documents_from_url 클라이언트 메서드

begin_recognize_identity_documents_from_url(identity_document_url: str, **kwargs: Any) -> LROPoller[List[RecognizedForm]]

매개 변수

identity_document_url
str
필수

분석할 ID 문서의 URL입니다. 입력은 지원되는 형식 중 하나인 JPEG, PNG, PDF, TIFF 또는 BMP의 유효한 인코딩된 URL이어야 합니다.

include_field_elements
bool

페이지당 모든 줄과 각 양식 필드의 선, 단어 및 선택 표시와 같은 필드 요소를 포함할지 여부입니다.

continuation_token
str

저장된 상태에서 폴러를 다시 시작하는 연속 토큰입니다.

pages
list[str]

다중 페이지 문서에 대한 사용자 지정 페이지 번호(PDF/TIFF). 결과에서 가져올 페이지 번호 및/또는 페이지 범위를 입력합니다. 페이지 범위의 경우 pages=["1-3", "5-6"]와 같은 하이픈을 사용합니다. 각 페이지 번호 또는 범위를 쉼표로 구분합니다.

반환

LROPoller의 instance. poller 개체에서 result() 를 호출하여 목록[RecognizedForm]을 반환합니다.

반환 형식

예외

begin_recognize_invoices

지정된 청구서에서 필드 텍스트 및 의미 체계 값을 추출합니다. 입력 문서는 지원되는 콘텐츠 형식 중 하나여야 합니다( 'application/pdf', 'image/jpeg', 'image/png', 'image/tiff' 또는 'image/bmp').

청구서에 있는 필드를 참조하세요. https://aka.ms/formrecognizer/invoicefields

버전 v2.1의 새로운 기능: begin_recognize_invoices 클라이언트 메서드

begin_recognize_invoices(invoice: bytes | IO[bytes], **kwargs: Any) -> LROPoller[List[RecognizedForm]]

매개 변수

invoice
bytes 또는 IO[bytes]
필수

JPEG, PNG, PDF, TIFF 또는 BMP 형식 파일 스트림 또는 바이트.

locale
str

청구서의 로캘입니다. 지원되는 로캘은 다음과 같습니다. en-US

include_field_elements
bool

페이지당 모든 줄과 각 양식 필드의 선, 단어 및 선택 표시와 같은 필드 요소를 포함할지 여부입니다.

pages
list[str]

다중 페이지 문서에 대한 사용자 지정 페이지 번호(PDF/TIFF). 결과에서 가져올 페이지 번호 및/또는 페이지 범위를 입력합니다. 페이지 범위의 경우 pages=["1-3", "5-6"]와 같은 하이픈을 사용합니다. 각 페이지 번호 또는 범위를 쉼표로 구분합니다.

content_type
str 또는 FormContentType

API로 전송된 본문의 콘텐츠 형식입니다. 콘텐츠 형식은 자동 검색되지만 이 키워드(keyword) 인수를 전달하여 재정의할 수 있습니다. 옵션은 를 참조하세요 FormContentType.

continuation_token
str

저장된 상태에서 폴러를 다시 시작하는 연속 토큰입니다.

반환

LROPoller의 instance. poller 개체에서 result() 를 호출하여 목록[RecognizedForm]을 반환합니다.

반환 형식

예외

예제

파일에서 청구서를 인식합니다.


   from azure.core.credentials import AzureKeyCredential
   from azure.ai.formrecognizer import FormRecognizerClient

   endpoint = os.environ["AZURE_FORM_RECOGNIZER_ENDPOINT"]
   key = os.environ["AZURE_FORM_RECOGNIZER_KEY"]

   form_recognizer_client = FormRecognizerClient(
       endpoint=endpoint, credential=AzureKeyCredential(key)
   )
   with open(path_to_sample_forms, "rb") as f:
       poller = form_recognizer_client.begin_recognize_invoices(invoice=f, locale="en-US")
   invoices = poller.result()

   for idx, invoice in enumerate(invoices):
       print("--------Recognizing invoice #{}--------".format(idx+1))
       vendor_name = invoice.fields.get("VendorName")
       if vendor_name:
           print("Vendor Name: {} has confidence: {}".format(vendor_name.value, vendor_name.confidence))
       vendor_address = invoice.fields.get("VendorAddress")
       if vendor_address:
           print("Vendor Address: {} has confidence: {}".format(vendor_address.value, vendor_address.confidence))
       vendor_address_recipient = invoice.fields.get("VendorAddressRecipient")
       if vendor_address_recipient:
           print("Vendor Address Recipient: {} has confidence: {}".format(vendor_address_recipient.value, vendor_address_recipient.confidence))
       customer_name = invoice.fields.get("CustomerName")
       if customer_name:
           print("Customer Name: {} has confidence: {}".format(customer_name.value, customer_name.confidence))
       customer_id = invoice.fields.get("CustomerId")
       if customer_id:
           print("Customer Id: {} has confidence: {}".format(customer_id.value, customer_id.confidence))
       customer_address = invoice.fields.get("CustomerAddress")
       if customer_address:
           print("Customer Address: {} has confidence: {}".format(customer_address.value, customer_address.confidence))
       customer_address_recipient = invoice.fields.get("CustomerAddressRecipient")
       if customer_address_recipient:
           print("Customer Address Recipient: {} has confidence: {}".format(customer_address_recipient.value, customer_address_recipient.confidence))
       invoice_id = invoice.fields.get("InvoiceId")
       if invoice_id:
           print("Invoice Id: {} has confidence: {}".format(invoice_id.value, invoice_id.confidence))
       invoice_date = invoice.fields.get("InvoiceDate")
       if invoice_date:
           print("Invoice Date: {} has confidence: {}".format(invoice_date.value, invoice_date.confidence))
       invoice_total = invoice.fields.get("InvoiceTotal")
       if invoice_total:
           print("Invoice Total: {} has confidence: {}".format(invoice_total.value, invoice_total.confidence))
       due_date = invoice.fields.get("DueDate")
       if due_date:
           print("Due Date: {} has confidence: {}".format(due_date.value, due_date.confidence))
       purchase_order = invoice.fields.get("PurchaseOrder")
       if purchase_order:
           print("Purchase Order: {} has confidence: {}".format(purchase_order.value, purchase_order.confidence))
       billing_address = invoice.fields.get("BillingAddress")
       if billing_address:
           print("Billing Address: {} has confidence: {}".format(billing_address.value, billing_address.confidence))
       billing_address_recipient = invoice.fields.get("BillingAddressRecipient")
       if billing_address_recipient:
           print("Billing Address Recipient: {} has confidence: {}".format(billing_address_recipient.value, billing_address_recipient.confidence))
       shipping_address = invoice.fields.get("ShippingAddress")
       if shipping_address:
           print("Shipping Address: {} has confidence: {}".format(shipping_address.value, shipping_address.confidence))
       shipping_address_recipient = invoice.fields.get("ShippingAddressRecipient")
       if shipping_address_recipient:
           print("Shipping Address Recipient: {} has confidence: {}".format(shipping_address_recipient.value, shipping_address_recipient.confidence))
       print("Invoice items:")
       for idx, item in enumerate(invoice.fields.get("Items").value):
           print("...Item #{}".format(idx+1))
           item_description = item.value.get("Description")
           if item_description:
               print("......Description: {} has confidence: {}".format(item_description.value, item_description.confidence))
           item_quantity = item.value.get("Quantity")
           if item_quantity:
               print("......Quantity: {} has confidence: {}".format(item_quantity.value, item_quantity.confidence))
           unit = item.value.get("Unit")
           if unit:
               print("......Unit: {} has confidence: {}".format(unit.value, unit.confidence))
           unit_price = item.value.get("UnitPrice")
           if unit_price:
               print("......Unit Price: {} has confidence: {}".format(unit_price.value, unit_price.confidence))
           product_code = item.value.get("ProductCode")
           if product_code:
               print("......Product Code: {} has confidence: {}".format(product_code.value, product_code.confidence))
           item_date = item.value.get("Date")
           if item_date:
               print("......Date: {} has confidence: {}".format(item_date.value, item_date.confidence))
           tax = item.value.get("Tax")
           if tax:
               print("......Tax: {} has confidence: {}".format(tax.value, tax.confidence))
           amount = item.value.get("Amount")
           if amount:
               print("......Amount: {} has confidence: {}".format(amount.value, amount.confidence))
       subtotal = invoice.fields.get("SubTotal")
       if subtotal:
           print("Subtotal: {} has confidence: {}".format(subtotal.value, subtotal.confidence))
       total_tax = invoice.fields.get("TotalTax")
       if total_tax:
           print("Total Tax: {} has confidence: {}".format(total_tax.value, total_tax.confidence))
       previous_unpaid_balance = invoice.fields.get("PreviousUnpaidBalance")
       if previous_unpaid_balance:
           print("Previous Unpaid Balance: {} has confidence: {}".format(previous_unpaid_balance.value, previous_unpaid_balance.confidence))
       amount_due = invoice.fields.get("AmountDue")
       if amount_due:
           print("Amount Due: {} has confidence: {}".format(amount_due.value, amount_due.confidence))
       service_start_date = invoice.fields.get("ServiceStartDate")
       if service_start_date:
           print("Service Start Date: {} has confidence: {}".format(service_start_date.value, service_start_date.confidence))
       service_end_date = invoice.fields.get("ServiceEndDate")
       if service_end_date:
           print("Service End Date: {} has confidence: {}".format(service_end_date.value, service_end_date.confidence))
       service_address = invoice.fields.get("ServiceAddress")
       if service_address:
           print("Service Address: {} has confidence: {}".format(service_address.value, service_address.confidence))
       service_address_recipient = invoice.fields.get("ServiceAddressRecipient")
       if service_address_recipient:
           print("Service Address Recipient: {} has confidence: {}".format(service_address_recipient.value, service_address_recipient.confidence))
       remittance_address = invoice.fields.get("RemittanceAddress")
       if remittance_address:
           print("Remittance Address: {} has confidence: {}".format(remittance_address.value, remittance_address.confidence))
       remittance_address_recipient = invoice.fields.get("RemittanceAddressRecipient")
       if remittance_address_recipient:
           print("Remittance Address Recipient: {} has confidence: {}".format(remittance_address_recipient.value, remittance_address_recipient.confidence))

begin_recognize_invoices_from_url

지정된 청구서에서 필드 텍스트 및 의미 체계 값을 추출합니다. 입력 문서는 분석할 청구서의 위치(URL)여야 합니다.

여기에서 청구서 카드 찾은 필드를 참조하세요.https://aka.ms/formrecognizer/invoicefields

버전 v2.1의 새로운 기능: begin_recognize_invoices_from_url 클라이언트 메서드

begin_recognize_invoices_from_url(invoice_url: str, **kwargs: Any) -> LROPoller[List[RecognizedForm]]

매개 변수

invoice_url
str
필수

분석할 청구서의 URL입니다. 입력은 지원되는 형식 중 하나인 JPEG, PNG, PDF, TIFF 또는 BMP의 유효한 인코딩된 URL이어야 합니다.

locale
str

청구서의 로캘입니다. 지원되는 로캘은 다음과 같습니다. en-US

include_field_elements
bool

페이지당 모든 줄과 각 양식 필드의 선, 단어 및 선택 표시와 같은 필드 요소를 포함할지 여부입니다.

pages
list[str]

다중 페이지 문서에 대한 사용자 지정 페이지 번호(PDF/TIFF). 결과에서 가져올 페이지 번호 및/또는 페이지 범위를 입력합니다. 페이지 범위의 경우 pages=["1-3", "5-6"]와 같은 하이픈을 사용합니다. 각 페이지 번호 또는 범위를 쉼표로 구분합니다.

continuation_token
str

저장된 상태에서 폴러를 다시 시작하는 연속 토큰입니다.

반환

LROPoller의 instance. poller 개체에서 result() 를 호출하여 목록[RecognizedForm]을 반환합니다.

반환 형식

예외

begin_recognize_receipts

지정된 판매 영수증에서 필드 텍스트 및 의미 체계 값을 추출합니다. 입력 문서는 지원되는 콘텐츠 형식 중 하나여야 합니다( 'application/pdf', 'image/jpeg', 'image/png', 'image/tiff' 또는 'image/bmp').

영수증에서 찾은 필드를 참조하세요. https://aka.ms/formrecognizer/receiptfields

버전 v2.1의 새로운 기능: 이미지/bmp 콘텐츠에 대한 인수 및 지원을 키워드(keyword) 로캘페이지

begin_recognize_receipts(receipt: bytes | IO[bytes], **kwargs: Any) -> LROPoller[List[RecognizedForm]]

매개 변수

receipt
bytes 또는 IO[bytes]
필수

JPEG, PNG, PDF, TIFF 또는 BMP 형식 파일 스트림 또는 바이트.

include_field_elements
bool

페이지당 모든 줄과 각 양식 필드의 선, 단어 및 선택 표시와 같은 필드 요소를 포함할지 여부입니다.

content_type
str 또는 FormContentType

API로 전송된 본문의 콘텐츠 형식입니다. 콘텐츠 형식은 자동 검색되지만 이 키워드(keyword) 인수를 전달하여 재정의할 수 있습니다. 옵션은 를 참조하세요 FormContentType.

continuation_token
str

저장된 상태에서 폴러를 다시 시작하는 연속 토큰입니다.

locale
str

영수증의 로캘입니다. 지원되는 로캘에는 en-US, en-AU, en-CA, en-GB 및 en-IN이 포함됩니다.

pages
list[str]

다중 페이지 문서에 대한 사용자 지정 페이지 번호(PDF/TIFF). 결과에서 가져올 페이지 번호 및/또는 페이지 범위를 입력합니다. 페이지 범위의 경우 pages=["1-3", "5-6"]와 같은 하이픈을 사용합니다. 각 페이지 번호 또는 범위를 쉼표로 구분합니다.

반환

LROPoller의 instance. poller 개체에서 result() 를 호출하여 목록[RecognizedForm]을 반환합니다.

반환 형식

예외

예제

판매 영수증 필드를 인식합니다.


   from azure.core.credentials import AzureKeyCredential
   from azure.ai.formrecognizer import FormRecognizerClient

   endpoint = os.environ["AZURE_FORM_RECOGNIZER_ENDPOINT"]
   key = os.environ["AZURE_FORM_RECOGNIZER_KEY"]

   form_recognizer_client = FormRecognizerClient(
       endpoint=endpoint, credential=AzureKeyCredential(key)
   )
   with open(path_to_sample_forms, "rb") as f:
       poller = form_recognizer_client.begin_recognize_receipts(receipt=f, locale="en-US")
   receipts = poller.result()

   for idx, receipt in enumerate(receipts):
       print("--------Recognizing receipt #{}--------".format(idx+1))
       receipt_type = receipt.fields.get("ReceiptType")
       if receipt_type:
           print("Receipt Type: {} has confidence: {}".format(receipt_type.value, receipt_type.confidence))
       merchant_name = receipt.fields.get("MerchantName")
       if merchant_name:
           print("Merchant Name: {} has confidence: {}".format(merchant_name.value, merchant_name.confidence))
       transaction_date = receipt.fields.get("TransactionDate")
       if transaction_date:
           print("Transaction Date: {} has confidence: {}".format(transaction_date.value, transaction_date.confidence))
       if receipt.fields.get("Items"):
           print("Receipt items:")
           for idx, item in enumerate(receipt.fields.get("Items").value):
               print("...Item #{}".format(idx+1))
               item_name = item.value.get("Name")
               if item_name:
                   print("......Item Name: {} has confidence: {}".format(item_name.value, item_name.confidence))
               item_quantity = item.value.get("Quantity")
               if item_quantity:
                   print("......Item Quantity: {} has confidence: {}".format(item_quantity.value, item_quantity.confidence))
               item_price = item.value.get("Price")
               if item_price:
                   print("......Individual Item Price: {} has confidence: {}".format(item_price.value, item_price.confidence))
               item_total_price = item.value.get("TotalPrice")
               if item_total_price:
                   print("......Total Item Price: {} has confidence: {}".format(item_total_price.value, item_total_price.confidence))
       subtotal = receipt.fields.get("Subtotal")
       if subtotal:
           print("Subtotal: {} has confidence: {}".format(subtotal.value, subtotal.confidence))
       tax = receipt.fields.get("Tax")
       if tax:
           print("Tax: {} has confidence: {}".format(tax.value, tax.confidence))
       tip = receipt.fields.get("Tip")
       if tip:
           print("Tip: {} has confidence: {}".format(tip.value, tip.confidence))
       total = receipt.fields.get("Total")
       if total:
           print("Total: {} has confidence: {}".format(total.value, total.confidence))
       print("--------------------------------------")

begin_recognize_receipts_from_url

지정된 판매 영수증에서 필드 텍스트 및 의미 체계 값을 추출합니다. 입력 문서는 분석할 영수증의 위치(URL)여야 합니다.

영수증에서 찾은 필드를 참조하세요. https://aka.ms/formrecognizer/receiptfields

버전 v2.1의 새로운 기능: 이미지/bmp 콘텐츠에 대한 인수 및 지원을 키워드(keyword) 로캘페이지

begin_recognize_receipts_from_url(receipt_url: str, **kwargs: Any) -> LROPoller[List[RecognizedForm]]

매개 변수

receipt_url
str
필수

분석할 영수증의 URL입니다. 입력은 지원되는 형식 중 하나인 JPEG, PNG, PDF, TIFF 또는 BMP의 유효한 인코딩된 URL이어야 합니다.

include_field_elements
bool

페이지당 모든 줄과 각 양식 필드의 선, 단어 및 선택 표시와 같은 필드 요소를 포함할지 여부입니다.

continuation_token
str

저장된 상태에서 폴러를 다시 시작하는 연속 토큰입니다.

locale
str

영수증의 로캘입니다. 지원되는 로캘에는 en-US, en-AU, en-CA, en-GB 및 en-IN이 포함됩니다.

pages
list[str]

다중 페이지 문서에 대한 사용자 지정 페이지 번호(PDF/TIFF). 결과에서 가져올 페이지 번호 및/또는 페이지 범위를 입력합니다. 페이지 범위의 경우 pages=["1-3", "5-6"]와 같은 하이픈을 사용합니다. 각 페이지 번호 또는 범위를 쉼표로 구분합니다.

반환

LROPoller의 instance. poller 개체에서 result() 를 호출하여 목록[RecognizedForm]을 반환합니다.

반환 형식

예외

예제

URL에서 판매 영수증 필드를 인식합니다.


   from azure.core.credentials import AzureKeyCredential
   from azure.ai.formrecognizer import FormRecognizerClient

   endpoint = os.environ["AZURE_FORM_RECOGNIZER_ENDPOINT"]
   key = os.environ["AZURE_FORM_RECOGNIZER_KEY"]

   form_recognizer_client = FormRecognizerClient(
       endpoint=endpoint, credential=AzureKeyCredential(key)
   )
   url = "https://raw.githubusercontent.com/Azure/azure-sdk-for-python/main/sdk/formrecognizer/azure-ai-formrecognizer/tests/sample_forms/receipt/contoso-receipt.png"
   poller = form_recognizer_client.begin_recognize_receipts_from_url(receipt_url=url)
   receipts = poller.result()

   for idx, receipt in enumerate(receipts):
       print("--------Recognizing receipt #{}--------".format(idx+1))
       receipt_type = receipt.fields.get("ReceiptType")
       if receipt_type:
           print("Receipt Type: {} has confidence: {}".format(receipt_type.value, receipt_type.confidence))
       merchant_name = receipt.fields.get("MerchantName")
       if merchant_name:
           print("Merchant Name: {} has confidence: {}".format(merchant_name.value, merchant_name.confidence))
       transaction_date = receipt.fields.get("TransactionDate")
       if transaction_date:
           print("Transaction Date: {} has confidence: {}".format(transaction_date.value, transaction_date.confidence))
       if receipt.fields.get("Items"):
           print("Receipt items:")
           for idx, item in enumerate(receipt.fields.get("Items").value):
               print("...Item #{}".format(idx+1))
               item_name = item.value.get("Name")
               if item_name:
                   print("......Item Name: {} has confidence: {}".format(item_name.value, item_name.confidence))
               item_quantity = item.value.get("Quantity")
               if item_quantity:
                   print("......Item Quantity: {} has confidence: {}".format(item_quantity.value, item_quantity.confidence))
               item_price = item.value.get("Price")
               if item_price:
                   print("......Individual Item Price: {} has confidence: {}".format(item_price.value, item_price.confidence))
               item_total_price = item.value.get("TotalPrice")
               if item_total_price:
                   print("......Total Item Price: {} has confidence: {}".format(item_total_price.value, item_total_price.confidence))
       subtotal = receipt.fields.get("Subtotal")
       if subtotal:
           print("Subtotal: {} has confidence: {}".format(subtotal.value, subtotal.confidence))
       tax = receipt.fields.get("Tax")
       if tax:
           print("Tax: {} has confidence: {}".format(tax.value, tax.confidence))
       tip = receipt.fields.get("Tip")
       if tip:
           print("Tip: {} has confidence: {}".format(tip.value, tip.confidence))
       total = receipt.fields.get("Total")
       if total:
           print("Total: {} has confidence: {}".format(total.value, total.confidence))
       print("--------------------------------------")

close

세션을 닫습니다 FormRecognizerClient .

close() -> None

예외

send_request

클라이언트의 기존 파이프라인을 사용하여 네트워크 요청을 실행합니다.

요청 URL은 기본 URL을 기준으로 할 수 있습니다. 요청에 사용되는 서비스 API 버전은 달리 지정하지 않는 한 클라이언트의 버전과 동일합니다. 상대 URL에서 클라이언트의 구성된 API 버전을 재정의하는 것은 API 버전 2022-08-31 이상을 사용하는 클라이언트에서 지원됩니다. 모든 API 버전으로 클라이언트에서 지원되는 절대 URL의 재정의. 응답이 오류인 경우 이 메서드는 발생하지 않습니다. 예외를 발생하려면 반환된 응답 개체에서 raise_for_status() 를 호출합니다. 이 메서드를 사용하여 사용자 지정 요청을 보내는 방법에 대한 자세한 내용은 을 참조하세요 https://aka.ms/azsdk/dpcodegen/python/send_request.

send_request(request: HttpRequest, *, stream: bool = False, **kwargs) -> HttpResponse

매개 변수

request
HttpRequest
필수

만들려는 네트워크 요청입니다.

stream
bool

응답 페이로드가 스트리밍될지 여부입니다. 기본값은 False입니다.

반환

네트워크 호출의 응답입니다. 응답에 대한 오류 처리는 수행하지 않습니다.

반환 형식

예외