You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: notebooks/field_extraction.ipynb
+34-32Lines changed: 34 additions & 32 deletions
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@
20
20
"source": [
21
21
"## Prerequisites\n",
22
22
"1. Please ensure your Azure AI service is configured by following the [configuration steps](../README.md#configure-azure-ai-service-resource).\n",
23
-
"2. Install the required packages to run this sample."
23
+
"2. Please install the required packages to run this sample."
24
24
]
25
25
},
26
26
{
@@ -38,12 +38,12 @@
38
38
"source": [
39
39
"## Create Azure AI Content Understanding Client\n",
40
40
"\n",
41
-
"> The [AzureContentUnderstandingClient](../python/content_understanding_client.py) is a utility class providing functions to interact with the Content Understanding API. Before the official release of the Content Understanding SDK, it acts as a lightweight SDK. Please fill in the constants **AZURE_AI_ENDPOINT** and **AZURE_AI_API_VERSION** with your Azure AI Service information. Optionally, you may provide **AZURE_AI_API_KEY** if your setup requires key-based authentication.\n",
41
+
"> The [AzureContentUnderstandingClient](../python/content_understanding_client.py) is a utility class providing functions to interact with the Content Understanding API. Before the official release of the Content Understanding SDK, this acts as a lightweight SDK. Please fill in the constants **AZURE_AI_ENDPOINT** and **AZURE_AI_API_VERSION** with your Azure AI Service information. Optionally, you may provide **AZURE_AI_API_KEY** if your setup requires key-based authentication.\n",
42
42
"\n",
43
43
"> ⚠️ Important:\n",
44
44
"Please update the code below to match your Azure authentication method.\n",
45
45
"Look for the `# IMPORTANT` comments and modify those sections accordingly.\n",
46
-
"Skipping this step may cause the sample to not run correctly.\n",
46
+
"Skipping this step may prevent the sample from running correctly.\n",
47
47
"\n",
48
48
"> ⚠️ Note: Using a subscription key works, but using a token provider with Azure Active Directory (AAD) is safer and highly recommended for production environments."
49
49
]
@@ -105,11 +105,11 @@
105
105
"This notebook demonstrates field extraction across multiple modalities using Azure AI Content Understanding. We will walk through each modality step-by-step:\n",
106
106
"\n",
107
107
"1. **Document Analysis** - Extract fields from invoices and receipts\n",
108
-
"2. **Audio Analysis** - Process call recordings and conversational audio\n",
108
+
"2. **Audio Analysis** - Process call recordings and conversational audio\n",
109
109
"3. **Video Analysis** - Analyze marketing videos and extract insights\n",
110
110
"4. **Image Analysis** - Extract information from charts and images\n",
111
111
"\n",
112
-
"Each section will create an analyzer, process sample data, display results, and clean up the analyzer before moving on to the next modality."
112
+
"Each section will create an analyzer, process sample data, display results, and clean up the analyzer before moving to the next modality."
113
113
]
114
114
},
115
115
{
@@ -122,7 +122,7 @@
122
122
"\n",
123
123
"**Key Schema Components:**\n",
124
124
"\n",
125
-
"- **`baseAnalyzerId`**: Crucial setting that specifies the prebuilt analyzer to derive from (e.g., `prebuilt-documentAnalyzer`, `prebuilt-audioAnalyzer`, `prebuilt-videoAnalyzer`, `prebuilt-imageAnalyzer`, `prebuilt-callCenter`). This provides foundational capabilities for your custom analyzer.\n",
125
+
"- **`baseAnalyzerId`**: Crucial setting specifying the prebuilt analyzer to derive from (e.g., `prebuilt-documentAnalyzer`, `prebuilt-audioAnalyzer`, `prebuilt-videoAnalyzer`, `prebuilt-imageAnalyzer`, `prebuilt-callCenter`). This provides foundational capabilities for your custom analyzer.\n",
126
126
"\n",
127
127
"- **`fields`**: Defines specific data points to extract. Each field includes:\n",
128
128
" - **Field name**: Identifier for the extracted data (required and important for referencing results)\n",
@@ -256,7 +256,7 @@
256
256
"source": [
257
257
"**Clean Up Invoice Analyzer**\n",
258
258
"\n",
259
-
"Optionally clean up the analyzer to manage resources (in production, analyzers are typically kept for reuse):"
259
+
"Optionally, clean up the analyzer to manage resources (typically, analyzers are kept for reuse in production):"
260
260
]
261
261
},
262
262
{
@@ -276,7 +276,7 @@
276
276
"\n",
277
277
"Now, let's analyze the same invoice but with enhanced field source information and confidence scores. This provides additional context about the location of each extracted field within the document.\n",
278
278
"\n",
279
-
"**Note**: This custom analyzer is for demonstration purposes only. In production, please start from `prebuilt-invoice` for invoice processing.\n",
279
+
"**Note**: This custom analyzer is for demonstration purposes only. For production, please start from `prebuilt-invoice` for invoice processing.\n",
280
280
"\n",
281
281
"**Key Feature**: This analyzer template uses `estimateFieldSourceAndConfidence: true` in the 'config', enabling the service to provide detailed information about:\n",
282
282
"- **Field source locations**: Exact coordinates and bounding boxes indicating where each field was found\n",
@@ -350,7 +350,7 @@
350
350
"source": [
351
351
"**Clean Up Invoice Field Source Analyzer**\n",
352
352
"\n",
353
-
"Optionally clean up the field source analyzer:"
353
+
"Optionally, clean up the field source analyzer:"
354
354
]
355
355
},
356
356
{
@@ -439,7 +439,7 @@
439
439
"source": [
440
440
"**Clean Up Receipt Analyzer**\n",
441
441
"\n",
442
-
"Optionally clean up the receipt analyzer:"
442
+
"Optionally, clean up the receipt analyzer:"
443
443
]
444
444
},
445
445
{
@@ -552,7 +552,7 @@
552
552
"source": [
553
553
"## 5. Conversational Audio Analytics\n",
554
554
"\n",
555
-
"Let's analyze the same audio file with a focus on conversational aspects like sentiment analysis and dialogue understanding.\n",
555
+
"Let's analyze the same audio file focusing on conversational aspects such as sentiment analysis and dialogue understanding.\n",
556
556
"\n",
557
557
"Conversational audio analytics template:"
558
558
]
@@ -645,23 +645,25 @@
645
645
"source": [
646
646
"## 6. Marketing Video Analysis\n",
647
647
"\n",
648
-
"Let's analyze a marketing video to extract descriptions, sentiment, and key insights that could be valuable for content understanding and marketing analytics.\n",
648
+
"Let's analyze a marketing video to extract descriptions, sentiment, and key insights valuable for content understanding and marketing analytics.\n",
649
649
"\n",
650
650
"Content Understanding offers three segmentation options to slice a video, enabling you to get output for entire videos or short clips. You can specify these by setting the `segmentationMode` property in your custom analyzer:\n",
" The service analyzes the timeline, automatically segmenting the video. It groups successive shots into coherent scenes, capped at one minute each.\n",
" The service analyzes the timeline, automatically segmenting the video. It groups successive shots into coherent scenes, capped at one minute each.\n",
" You describe the segmentation logic in natural language, and the model creates segments accordingly. Set `segmentationDefinition` with a string describing your desired segmentation. Custom segmentation allows segments of varying length from seconds to minutes.\n",
" You describe the segmentation logic in natural language, and the model creates segments accordingly. Set `segmentationDefinition` with a string describing your desired segmentation. Custom segmentation allows segments of varying length from seconds to minutes.\n",
663
663
" Example:\n",
664
-
" - Breaking a news broadcast into distinct stories"
664
+
" - Breaking a news broadcast into distinct stories\n",
665
+
"\n",
666
+
"> Important: The defined fields for segment analysis must be declared under `fieldSchema` → `fields` → `Segments` when setting `\"segmentationMode\"` as `\"auto\"` or `\"custom\"`. We will use the same set of fields for each video segment. You won't be able to create the analyzer successfully if other fields are set under `fieldSchema` → `fields`. In other words, whole video analysis cannot be combined with segment analysis."
665
667
]
666
668
},
667
669
{
@@ -754,9 +756,9 @@
754
756
"source": [
755
757
"### 6-2 Analyze With Automatic Segmentation\n",
756
758
"\n",
757
-
"In this example, we use automatic segmentation for marketing video analytics.\n",
759
+
"In this example, we use automatic segmentation for marketing video analytics.\n",
758
760
"- Please set `segmentationMode` to `auto` in the analyzer schema `config` to enable automatic segmentation.\n",
759
-
"- The defined fields for segment analysis must be declared under `fieldSchema` → `Segments`."
761
+
"- The defined fields for segment analysis must be declared under `fieldSchema` → `fields` → `Segments`."
760
762
]
761
763
},
762
764
{
@@ -803,7 +805,7 @@
803
805
"metadata": {},
804
806
"source": [
805
807
"Marketing video analysis result:\n",
806
-
"- The output includes automatically segmented clips with descriptions in the markdown content.\n",
808
+
"- The output includes automatically segmented clips with descriptions in the markdown content.\n",
807
809
"- The analyzer generates the fields defined in the schema separately for each segment."
808
810
]
809
811
},
@@ -840,10 +842,10 @@
840
842
"source": [
841
843
"### 6-3 Analyze With Custom Segmentation\n",
842
844
"\n",
843
-
"In this example, we use custom segmentation for marketing video analytics.\n",
844
-
"- Please set `segmentationMode` to `custom`.\n",
845
+
"In this example, we use custom segmentation for marketing video analytics.\n",
846
+
"- Please set `segmentationMode` to `custom`.\n",
845
847
"- Provide a `segmentationDefinition` string describing how you'd like the video to be segmented.\n",
846
-
"- The defined fields for segment analysis must be declared under `fieldSchema` → `Segments`."
848
+
"- The defined fields for segment analysis must be declared under `fieldSchema` → `fields` → `Segments`."
847
849
]
848
850
},
849
851
{
@@ -890,8 +892,8 @@
890
892
"metadata": {},
891
893
"source": [
892
894
"Marketing video analysis result:\n",
893
-
"- The video is segmented according to your custom definition, with segment descriptions included in the markdown content.\n",
894
-
"- The segmentation may differ from automatic segmentation results.\n",
895
+
"- The video is segmented according to your custom definition, with segment descriptions included in the markdown content.\n",
896
+
"- The segmentation may differ from automatic segmentation results.\n",
895
897
"- The analyzer generates the fields defined in the schema separately for each segment."
896
898
]
897
899
},
@@ -1021,9 +1023,9 @@
1021
1023
"\n",
1022
1024
"🎉 **Congratulations!** You have successfully explored all the major modalities of Azure AI Content Understanding:\n",
1023
1025
"\n",
1024
-
"✅ **Document Analysis**: Extracted fields from invoices and receipts\n",
1025
-
"✅ **Audio Analysis**: Analyzed call recordings and conversational audio\n",
1026
-
"✅ **Video Analysis**: Processed marketing videos for insights\n",
1026
+
"✅ **Document Analysis**: Extracted fields from invoices and receipts\n",
1027
+
"✅ **Audio Analysis**: Analyzed call recordings and conversational audio\n",
1028
+
"✅ **Video Analysis**: Processed marketing videos for insights\n",
1027
1029
"✅ **Image Analysis**: Extracted information from charts and visual content\n",
0 commit comments