ينطبق هذا المحتوى على:v4.0 (معاينة) | الإصدارات السابقة: v3.1 (GA)
ينطبق هذا المحتوى على:v3.1 (GA) | أحدث إصدار: v4.0 (معاينة)
إشعار
تتوفر قدرات الوظيفة الإضافية داخل جميع النماذج باستثناء نموذج بطاقة العمل.
القدرات
يدعم Document Intelligence قدرات تحليل أكثر تعقيدا ونمطية. استخدم ميزات الوظيفة الإضافية لتوسيع النتائج لتضمين المزيد من الميزات المستخرجة من مستنداتك. تتحمل بعض ميزات الوظيفة الإضافية تكلفة إضافية. يمكن تمكين هذه الميزات الاختيارية وتعطيلها استنادا إلى سيناريو استخراج المستند. لتمكين ميزة، أضف اسم الميزة المقترنة features إلى خاصية سلسلة الاستعلام. يمكنك تمكين أكثر من ميزة إضافية واحدة على طلب من خلال توفير قائمة ميزات مفصولة بفواصل. تتوفر إمكانيات الوظيفة الإضافية التالية للإصدارات 2023-07-31 (GA) اللاحقة.
يختلف تنفيذ حقول الاستعلام في واجهة برمجة التطبيقات 2023-10-30-preview عن إصدار المعاينة الأخير. والتنفيذ الجديد أقل تكلفة ويعمل بشكل جيد مع الوثائق المنظمة.
✱ الوظيفة الإضافية - يتم تسعير حقول الاستعلام بشكل مختلف عن ميزات الوظيفة الإضافية الأخرى. للحصول على تفاصيل؛ تأكد من مراجعة الأسعار.
تنسيقات الملفات المعتمدة
PDF
الصور: JPEG/JPG، PNG، BMP، ، TIFFHEIF
✱ ملفات Microsoft Office غير مدعومة حاليا.
استخراج عالي الدقة
تمثل مهمة التعرف على النص الصغير من مستندات كبيرة الحجم، مثل الرسومات الهندسية، تحديا. غالبا ما يكون النص مختلطا بعناصر رسومية أخرى ويحتوي على خطوط وأحجام واتجاهات مختلفة. علاوة على ذلك، يمكن تقسيم النص إلى أجزاء منفصلة أو توصيله بالرموز الأخرى. يدعم Document Intelligence الآن استخراج المحتوى من هذه الأنواع من المستندات بالقدرة ocr.highResolution . يمكنك الحصول على جودة محسنة لاستخراج المحتوى من مستندات A1/A2/A3 عن طريق تمكين إمكانية الوظيفة الإضافية هذه.
# Analyze a document at a URL:
formUrl = "https://github.com/Azure-Samples/document-intelligence-code-samples/blob/main/Data/add-on/add-on-highres.png?raw=true"
poller = document_intelligence_client.begin_analyze_document(
"prebuilt-layout",
AnalyzeDocumentRequest(url_source=formUrl),
features=[DocumentAnalysisFeature.OCR_HIGH_RESOLUTION], # Specify which add-on capabilities to enable.
)
result: AnalyzeResult = poller.result()
# [START analyze_with_highres]
if result.styles and any([style.is_handwritten for style in result.styles]):
print("Document contains handwritten content")
else:
print("Document does not contain handwritten content")
for page in result.pages:
print(f"----Analyzing layout from page #{page.page_number}----")
print(f"Page has width: {page.width} and height: {page.height}, measured with unit: {page.unit}")
if page.lines:
for line_idx, line in enumerate(page.lines):
words = get_words(page, line)
print(
f"...Line # {line_idx} has word count {len(words)} and text '{line.content}' "
f"within bounding polygon '{line.polygon}'"
)
for word in words:
print(f"......Word '{word.content}' has a confidence of {word.confidence}")
if page.selection_marks:
for selection_mark in page.selection_marks:
print(
f"Selection mark is '{selection_mark.state}' within bounding polygon "
f"'{selection_mark.polygon}' and has a confidence of {selection_mark.confidence}"
)
if result.tables:
for table_idx, table in enumerate(result.tables):
print(f"Table # {table_idx} has {table.row_count} rows and " f"{table.column_count} columns")
if table.bounding_regions:
for region in table.bounding_regions:
print(f"Table # {table_idx} location on page: {region.page_number} is {region.polygon}")
for cell in table.cells:
print(f"...Cell[{cell.row_index}][{cell.column_index}] has text '{cell.content}'")
if cell.bounding_regions:
for region in cell.bounding_regions:
print(f"...content on page {region.page_number} is within bounding polygon '{region.polygon}'")
# Analyze a document at a URL:
url = "(https://github.com/Azure-Samples/document-intelligence-code-samples/blob/main/Data/add-on/add-on-highres.png?raw=true"
poller = document_analysis_client.begin_analyze_document_from_url(
"prebuilt-layout", document_url=url, features=[AnalysisFeature.OCR_HIGH_RESOLUTION] # Specify which add-on capabilities to enable.
)
result = poller.result()
# [START analyze_with_highres]
if any([style.is_handwritten for style in result.styles]):
print("Document contains handwritten content")
else:
print("Document does not contain handwritten content")
for page in result.pages:
print(f"----Analyzing layout from page #{page.page_number}----")
print(
f"Page has width: {page.width} and height: {page.height}, measured with unit: {page.unit}"
)
for line_idx, line in enumerate(page.lines):
words = line.get_words()
print(
f"...Line # {line_idx} has word count {len(words)} and text '{line.content}' "
f"within bounding polygon '{format_polygon(line.polygon)}'"
)
for word in words:
print(
f"......Word '{word.content}' has a confidence of {word.confidence}"
)
for selection_mark in page.selection_marks:
print(
f"Selection mark is '{selection_mark.state}' within bounding polygon "
f"'{format_polygon(selection_mark.polygon)}' and has a confidence of {selection_mark.confidence}"
)
for table_idx, table in enumerate(result.tables):
print(
f"Table # {table_idx} has {table.row_count} rows and "
f"{table.column_count} columns"
)
for region in table.bounding_regions:
print(
f"Table # {table_idx} location on page: {region.page_number} is {format_polygon(region.polygon)}"
)
for cell in table.cells:
print(
f"...Cell[{cell.row_index}][{cell.column_index}] has text '{cell.content}'"
)
for region in cell.bounding_regions:
print(
f"...content on page {region.page_number} is within bounding polygon '{format_polygon(region.polygon)}'"
)
تستخرج ocr.formula القدرة كافة الصيغ المحددة، مثل المعادلات الرياضية، في formulas المجموعة ككائن المستوى الأعلى ضمن content. داخل content، يتم تمثيل الصيغ المكتشفة ك :formula:. يمثل كل إدخال في هذه المجموعة صيغة تتضمن نوع الصيغة ك inline أو display، وتمثيل LaTeX الخاص بها جنبا value إلى جنب مع إحداثياتها polygon . في البداية، تظهر الصيغ في نهاية كل صفحة.
# Analyze a document at a URL:
formUrl = "https://github.com/Azure-Samples/document-intelligence-code-samples/blob/main/Data/add-on/layout-formulas.png?raw=true"
poller = document_intelligence_client.begin_analyze_document(
"prebuilt-layout",
AnalyzeDocumentRequest(url_source=formUrl),
features=[DocumentAnalysisFeature.FORMULAS], # Specify which add-on capabilities to enable
)
result: AnalyzeResult = poller.result()
# [START analyze_formulas]
for page in result.pages:
print(f"----Formulas detected from page #{page.page_number}----")
if page.formulas:
inline_formulas = [f for f in page.formulas if f.kind == "inline"]
display_formulas = [f for f in page.formulas if f.kind == "display"]
# To learn the detailed concept of "polygon" in the following content, visit: https://aka.ms/bounding-region
print(f"Detected {len(inline_formulas)} inline formulas.")
for formula_idx, formula in enumerate(inline_formulas):
print(f"- Inline #{formula_idx}: {formula.value}")
print(f" Confidence: {formula.confidence}")
print(f" Bounding regions: {formula.polygon}")
print(f"\nDetected {len(display_formulas)} display formulas.")
for formula_idx, formula in enumerate(display_formulas):
print(f"- Display #{formula_idx}: {formula.value}")
print(f" Confidence: {formula.confidence}")
print(f" Bounding regions: {formula.polygon}")
# Analyze a document at a URL:
url = "https://github.com/Azure-Samples/document-intelligence-code-samples/blob/main/Data/add-on/layout-formulas.png?raw=true"
poller = document_analysis_client.begin_analyze_document_from_url(
"prebuilt-layout", document_url=url, features=[AnalysisFeature.FORMULAS] # Specify which add-on capabilities to enable
)
result = poller.result()
# [START analyze_formulas]
for page in result.pages:
print(f"----Formulas detected from page #{page.page_number}----")
inline_formulas = [f for f in page.formulas if f.kind == "inline"]
display_formulas = [f for f in page.formulas if f.kind == "display"]
print(f"Detected {len(inline_formulas)} inline formulas.")
for formula_idx, formula in enumerate(inline_formulas):
print(f"- Inline #{formula_idx}: {formula.value}")
print(f" Confidence: {formula.confidence}")
print(f" Bounding regions: {format_polygon(formula.polygon)}")
print(f"\nDetected {len(display_formulas)} display formulas.")
for formula_idx, formula in enumerate(display_formulas):
print(f"- Display #{formula_idx}: {formula.value}")
print(f" Confidence: {formula.confidence}")
print(f" Bounding regions: {format_polygon(formula.polygon)}")
"content": ":formula:",
"pages": [
{
"pageNumber": 1,
"formulas": [
{
"kind": "inline",
"value": "\\frac { \\partial a } { \\partial b }",
"polygon": [...],
"span": {...},
"confidence": 0.99
},
{
"kind": "display",
"value": "y = a \\times b + a \\times c",
"polygon": [...],
"span": {...},
"confidence": 0.99
}
]
}
]
استخراج خاصية الخط
تستخرج ocr.font الإمكانية كافة خصائص الخط للنص المستخرج في styles المجموعة ككائن من المستوى الأعلى ضمن content. يحدد كل كائن نمط خاصية خط واحد، والنص الذي ينطبق عليه، ودرجة الثقة المقابلة له. يتم توسيع خاصية النمط الموجودة مع المزيد من خصائص الخط مثل similarFontFamily خط النص، fontStyle للأنماط مثل المائل والعادي، fontWeight للغامق أو العادي، color ولون النص، ولون backgroundColor مربع إحاطة النص.
# Analyze a document at a URL:
formUrl = "https://github.com/Azure-Samples/document-intelligence-code-samples/blob/main/Data/receipt/receipt-with-tips.png?raw=true"
poller = document_intelligence_client.begin_analyze_document(
"prebuilt-layout",
AnalyzeDocumentRequest(url_source=formUrl),
features=[DocumentAnalysisFeature.STYLE_FONT] # Specify which add-on capabilities to enable.
)
result: AnalyzeResult = poller.result()
# [START analyze_fonts]
# DocumentStyle has the following font related attributes:
similar_font_families = defaultdict(list) # e.g., 'Arial, sans-serif
font_styles = defaultdict(list) # e.g, 'italic'
font_weights = defaultdict(list) # e.g., 'bold'
font_colors = defaultdict(list) # in '#rrggbb' hexadecimal format
font_background_colors = defaultdict(list) # in '#rrggbb' hexadecimal format
if result.styles and any([style.is_handwritten for style in result.styles]):
print("Document contains handwritten content")
else:
print("Document does not contain handwritten content")
return
print("\n----Fonts styles detected in the document----")
# Iterate over the styles and group them by their font attributes.
for style in result.styles:
if style.similar_font_family:
similar_font_families[style.similar_font_family].append(style)
if style.font_style:
font_styles[style.font_style].append(style)
if style.font_weight:
font_weights[style.font_weight].append(style)
if style.color:
font_colors[style.color].append(style)
if style.background_color:
font_background_colors[style.background_color].append(style)
print(f"Detected {len(similar_font_families)} font families:")
for font_family, styles in similar_font_families.items():
print(f"- Font family: '{font_family}'")
print(f" Text: '{get_styled_text(styles, result.content)}'")
print(f"\nDetected {len(font_styles)} font styles:")
for font_style, styles in font_styles.items():
print(f"- Font style: '{font_style}'")
print(f" Text: '{get_styled_text(styles, result.content)}'")
print(f"\nDetected {len(font_weights)} font weights:")
for font_weight, styles in font_weights.items():
print(f"- Font weight: '{font_weight}'")
print(f" Text: '{get_styled_text(styles, result.content)}'")
print(f"\nDetected {len(font_colors)} font colors:")
for font_color, styles in font_colors.items():
print(f"- Font color: '{font_color}'")
print(f" Text: '{get_styled_text(styles, result.content)}'")
print(f"\nDetected {len(font_background_colors)} font background colors:")
for font_background_color, styles in font_background_colors.items():
print(f"- Font background color: '{font_background_color}'")
print(f" Text: '{get_styled_text(styles, result.content)}'")
# Analyze a document at a URL:
url = "https://github.com/Azure-Samples/document-intelligence-code-samples/blob/main/Data/receipt/receipt-with-tips.png?raw=true"
poller = document_analysis_client.begin_analyze_document_from_url(
"prebuilt-layout", document_url=url, features=[AnalysisFeature.STYLE_FONT] # Specify which add-on capabilities to enable.
)
result = poller.result()
# [START analyze_fonts]
# DocumentStyle has the following font related attributes:
similar_font_families = defaultdict(list) # e.g., 'Arial, sans-serif
font_styles = defaultdict(list) # e.g, 'italic'
font_weights = defaultdict(list) # e.g., 'bold'
font_colors = defaultdict(list) # in '#rrggbb' hexadecimal format
font_background_colors = defaultdict(list) # in '#rrggbb' hexadecimal format
if any([style.is_handwritten for style in result.styles]):
print("Document contains handwritten content")
else:
print("Document does not contain handwritten content")
print("\n----Fonts styles detected in the document----")
# Iterate over the styles and group them by their font attributes.
for style in result.styles:
if style.similar_font_family:
similar_font_families[style.similar_font_family].append(style)
if style.font_style:
font_styles[style.font_style].append(style)
if style.font_weight:
font_weights[style.font_weight].append(style)
if style.color:
font_colors[style.color].append(style)
if style.background_color:
font_background_colors[style.background_color].append(style)
print(f"Detected {len(similar_font_families)} font families:")
for font_family, styles in similar_font_families.items():
print(f"- Font family: '{font_family}'")
print(f" Text: '{get_styled_text(styles, result.content)}'")
print(f"\nDetected {len(font_styles)} font styles:")
for font_style, styles in font_styles.items():
print(f"- Font style: '{font_style}'")
print(f" Text: '{get_styled_text(styles, result.content)}'")
print(f"\nDetected {len(font_weights)} font weights:")
for font_weight, styles in font_weights.items():
print(f"- Font weight: '{font_weight}'")
print(f" Text: '{get_styled_text(styles, result.content)}'")
print(f"\nDetected {len(font_colors)} font colors:")
for font_color, styles in font_colors.items():
print(f"- Font color: '{font_color}'")
print(f" Text: '{get_styled_text(styles, result.content)}'")
print(f"\nDetected {len(font_background_colors)} font background colors:")
for font_background_color, styles in font_background_colors.items():
print(f"- Font background color: '{font_background_color}'")
print(f" Text: '{get_styled_text(styles, result.content)}'")
تستخرج ocr.barcode القدرة جميع الرموز الشريطية المحددة في barcodes المجموعة ككائن المستوى الأعلى ضمن content. contentداخل ، يتم تمثيل الرموز الشريطية المكتشفة ك :barcode:. يمثل كل إدخال في هذه المجموعة رمزا شريطيا ويتضمن نوع الرمز الشريطي ك kind ومحتوى الرمز الشريطي المضمن جنبا value إلى جنب مع إحداثياته polygon . في البداية، تظهر الرموز الشريطية في نهاية كل صفحة. هو confidence تعليمات برمجية مضمنة ل ك 1.
# Analyze a document at a URL:
url = "https://github.com/Azure-Samples/document-intelligence-code-samples/blob/main/Data/add-on/add-on-barcodes.jpg?raw=true"
poller = document_analysis_client.begin_analyze_document_from_url(
"prebuilt-layout", document_url=url, features=[AnalysisFeature.BARCODES] # Specify which add-on capabilities to enable.
)
result = poller.result()
# [START analyze_barcodes]
# Iterate over extracted barcodes on each page.
for page in result.pages:
print(f"----Barcodes detected from page #{page.page_number}----")
print(f"Detected {len(page.barcodes)} barcodes:")
for barcode_idx, barcode in enumerate(page.barcodes):
print(f"- Barcode #{barcode_idx}: {barcode.value}")
print(f" Kind: {barcode.kind}")
print(f" Confidence: {barcode.confidence}")
print(f" Bounding regions: {format_polygon(barcode.polygon)}")
# Analyze a document at a URL:
formUrl = "https://github.com/Azure-Samples/document-intelligence-code-samples/blob/main/Data/add-on/add-on-fonts_and_languages.png?raw=true"
poller = document_intelligence_client.begin_analyze_document(
"prebuilt-layout",
AnalyzeDocumentRequest(url_source=formUrl),
features=[DocumentAnalysisFeature.LANGUAGES] # Specify which add-on capabilities to enable.
)
result: AnalyzeResult = poller.result()
# [START analyze_languages]
print("----Languages detected in the document----")
if result.languages:
print(f"Detected {len(result.languages)} languages:")
for lang_idx, lang in enumerate(result.languages):
print(f"- Language #{lang_idx}: locale '{lang.locale}'")
print(f" Confidence: {lang.confidence}")
print(
f" Text: '{','.join([result.content[span.offset : span.offset + span.length] for span in lang.spans])}'"
)
# Analyze a document at a URL:
url = "https://github.com/Azure-Samples/document-intelligence-code-samples/blob/main/Data/add-on/add-on-fonts_and_languages.png?raw=true"
poller = document_analysis_client.begin_analyze_document_from_url(
"prebuilt-layout", document_url=url, features=[AnalysisFeature.LANGUAGES] # Specify which add-on capabilities to enable.
)
result = poller.result()
# [START analyze_languages]
print("----Languages detected in the document----")
print(f"Detected {len(result.languages)} languages:")
for lang_idx, lang in enumerate(result.languages):
print(f"- Language #{lang_idx}: locale '{lang.locale}'")
print(f" Confidence: {lang.confidence}")
print(f" Text: '{','.join([result.content[span.offset : span.offset + span.length] for span in lang.spans])}'")
في إصدارات واجهة برمجة التطبيقات السابقة، استخرج نموذج المستند الذي تم إنشاؤه مسبقا أزواج قيم المفاتيح من النماذج والمستندات. مع إضافة الميزة keyValuePairs إلى تخطيط مسبق الإنشاء، ينتج الآن نموذج التخطيط نفس النتائج.
أزواج قيم المفتاح هي امتدادات محددة داخل المستند تحدد التسمية أو المفتاح والاستجابة أو القيمة المرتبطة به. في شكل منظم، يمكن أن تكون هذه الأزواج هي التسمية والقيمة التي أدخلها المستخدم لهذا الحقل. في مستند غير منظم، يمكن أن يكون هذا هو التاريخ الذي تم فيه تنفيذ العقد بناءً على النص الموجود في فقرة. يتم تدريب نموذج الذكاء الاصطناعي على استخراج مفاتيح وقيم قابلة للتعريف استنادًا إلى مجموعة متنوعة من أنواع المستندات والتنسيقات والهياكل.
يمكن أيضًا أن توجد المفاتيح بشكل منفصل عندما يكتشف النموذج وجود مفتاح، بدون قيمة مرتبطة أو عند معالجة الحقول الاختيارية. على سبيل المثال، يمكن ترك حقل الاسم الأوسط فارغا في نموذج في بعض الحالات. تكون أزواج قيم المفاتيح عبارة عن امتداد للنص الموجود في المستند. بالنسبة للمستندات التي يتم وصف نفس القيمة فيها بطرق مختلفة، على سبيل المثال، العميل/المستخدم، يكون المفتاح المقترن إما عميلا أو مستخدما (استنادا إلى السياق).
حقول الاستعلام هي إمكانية إضافية لتوسيع المخطط المستخرج من أي نموذج تم إنشاؤه مسبقا أو تحديد اسم مفتاح معين عندما يكون اسم المفتاح متغيرا. لاستخدام حقول الاستعلام، قم بتعيين الميزات إلى queryFields وتوفير قائمة مفصولة بفواصل بأسماء الحقول في الخاصية queryFields .
يدعم Document Intelligence الآن عمليات استخراج حقل الاستعلام. باستخدام استخراج حقل الاستعلام، يمكنك إضافة حقول إلى عملية الاستخراج باستخدام طلب استعلام دون الحاجة إلى تدريب إضافي.
استخدم حقول الاستعلام عندما تحتاج إلى توسيع مخطط نموذج تم إنشاؤه مسبقا أو مخصص أو تحتاج إلى استخراج بعض الحقول باستخدام إخراج التخطيط.
حقول الاستعلام هي إمكانية إضافية متميزة. للحصول على أفضل النتائج، حدد الحقول التي تريد استخراجها باستخدام حالة الجمل أو أسماء حقول حالة باسكال لأسماء الحقول متعددة الكلمات.
تدعم حقول الاستعلام 20 حقلا كحد أقصى لكل طلب. إذا احتوى المستند على قيمة للحقل، إرجاع الحقل والقيمة.
يحتوي هذا الإصدار على تنفيذ جديد لقدرة حقول الاستعلام التي يتم تسعيرها أقل من التنفيذ السابق ويجب التحقق من صحتها.
إشعار
يتوفر استخراج حقل استعلام Document Intelligence Studio حاليا مع واجهة برمجة تطبيقات التخطيط والنماذج 2024-02-29-preview2023-10-31-preview التي تم إنشاؤها مسبقا والإصدارات الأحدث باستثناء US tax النماذج (نماذج W2 و1098s و1099s).
استخراج حقل الاستعلام
لاستخراج حقل الاستعلام، حدد الحقول التي تريد استخراجها وتحلل ذكاء المستند المستند وفقا لذلك. إليك مثال:
إذا كنت تعالج عقدا في Document Intelligence Studio، فاستخدم 2024-02-29-preview الإصدارين أو 2023-10-31-preview :
يمكنك تمرير قائمة تسميات الحقول مثل Party1و PaymentTermsTermsOfUsePaymentDateParty2TermEndDate كجزء من analyze document الطلب.
يمكن ل Document Intelligence تحليل بيانات الحقل واستخراجها وإرجاع القيم في إخراج JSON منظم.
بالإضافة إلى حقول الاستعلام، تتضمن الاستجابة النص والجداول وعلامات التحديد والبيانات الأخرى ذات الصلة.
# Analyze a document at a URL:
formUrl = "https://github.com/Azure-Samples/document-intelligence-code-samples/blob/main/Data/invoice/simple-invoice.png?raw=true"
poller = document_intelligence_client.begin_analyze_document(
"prebuilt-layout",
AnalyzeDocumentRequest(url_source=formUrl),
features=[DocumentAnalysisFeature.QUERY_FIELDS], # Specify which add-on capabilities to enable.
query_fields=["Address", "InvoiceNumber"], # Set the features and provide a comma-separated list of field names.
)
result: AnalyzeResult = poller.result()
print("Here are extra fields in result:\n")
if result.documents:
for doc in result.documents:
if doc.fields and doc.fields["Address"]:
print(f"Address: {doc.fields['Address'].value_string}")
if doc.fields and doc.fields["InvoiceNumber"]:
print(f"Invoice number: {doc.fields['InvoiceNumber'].value_string}")
قريبًا: خلال عام 2024، سنتخلص تدريجيًا من GitHub Issues بوصفها آلية إرسال ملاحظات للمحتوى ونستبدلها بنظام ملاحظات جديد. لمزيد من المعلومات، راجع https://aka.ms/ContentUserFeedback.