|
4 | 4 | "cell_type": "markdown",
|
5 | 5 | "metadata": {},
|
6 | 6 | "source": [
|
7 |
| - "# Manage Analyzers in Your Resource" |
| 7 | + "# Managing Analyzers in Your Resource" |
8 | 8 | ]
|
9 | 9 | },
|
10 | 10 | {
|
11 | 11 | "cell_type": "markdown",
|
12 | 12 | "metadata": {},
|
13 | 13 | "source": [
|
14 |
| - "This notebook demo how to create a simple analyzer and manage its lifecycle." |
| 14 | + "This notebook demonstrates how to create a simple analyzer and manage its lifecycle." |
15 | 15 | ]
|
16 | 16 | },
|
17 | 17 | {
|
18 | 18 | "cell_type": "markdown",
|
19 | 19 | "metadata": {},
|
20 | 20 | "source": [
|
21 | 21 | "## Prerequisites\n",
|
22 |
| - "1. Ensure Azure AI service is configured following [steps](../README.md#configure-azure-ai-service-resource)\n", |
23 |
| - "2. Install the required packages to run the sample." |
| 22 | + "1. Ensure your Azure AI service is configured following the [configuration steps](../README.md#configure-azure-ai-service-resource).\n", |
| 23 | + "2. Install the required packages to run this sample." |
24 | 24 | ]
|
25 | 25 | },
|
26 | 26 | {
|
|
36 | 36 | "cell_type": "markdown",
|
37 | 37 | "metadata": {},
|
38 | 38 | "source": [
|
39 |
| - "## Create Azure AI Content Understanding Client\n", |
| 39 | + "## Create the Azure AI Content Understanding Client\n", |
40 | 40 | "\n",
|
41 |
| - "> The [AzureContentUnderstandingClient](../python/content_understanding_client.py) is a utility class containing functions to interact with the Content Understanding API. Before the official release of the Content Understanding SDK, it can be regarded as a lightweight SDK. Fill the constant **AZURE_AI_ENDPOINT**, **AZURE_AI_API_VERSION**, **AZURE_AI_API_KEY** with the information from your Azure AI Service.\n", |
| 41 | + "> The [AzureContentUnderstandingClient](../python/content_understanding_client.py) is a utility class that provides functions to interact with the Content Understanding API. Before the official release of the Content Understanding SDK, this client serves as a lightweight SDK.\n", |
| 42 | + "\n", |
| 43 | + "> Fill the constants **AZURE_AI_ENDPOINT**, **AZURE_AI_API_VERSION**, and **AZURE_AI_API_KEY** with your Azure AI Service details.\n", |
42 | 44 | "\n",
|
43 | 45 | "> ⚠️ Important:\n",
|
44 |
| - "You must update the code below to match your Azure authentication method.\n", |
| 46 | + "Update the code below to match your Azure authentication method.\n", |
45 | 47 | "Look for the `# IMPORTANT` comments and modify those sections accordingly.\n",
|
46 |
| - "If you skip this step, the sample may not run correctly.\n", |
| 48 | + "If you skip this step, the sample might not run correctly.\n", |
47 | 49 | "\n",
|
48 |
| - "> ⚠️ Note: Using a subscription key works, but using a token provider with Azure Active Directory (AAD) is much safer and is highly recommended for production environments." |
| 50 | + "> ⚠️ Note: Using a subscription key works, but using Azure Active Directory (AAD) token-based authentication is more secure and highly recommended for production environments." |
49 | 51 | ]
|
50 | 52 | },
|
51 | 53 | {
|
|
65 | 67 | "load_dotenv(find_dotenv())\n",
|
66 | 68 | "logging.basicConfig(level=logging.INFO)\n",
|
67 | 69 | "\n",
|
68 |
| - "# For authentication, you can use either token-based auth or subscription key, and only one of them is required\n", |
| 70 | + "# For authentication, you can use either token-based auth or subscription key. Use only one of these methods.\n", |
69 | 71 | "AZURE_AI_ENDPOINT = os.getenv(\"AZURE_AI_ENDPOINT\")\n",
|
70 |
| - "# IMPORTANT: Replace with your actual subscription key or set up in \".env\" file if not using token auth\n", |
| 72 | + "# IMPORTANT: Replace with your actual subscription key or set it in your \".env\" file if not using token auth\n", |
71 | 73 | "AZURE_AI_API_KEY = os.getenv(\"AZURE_AI_API_KEY\")\n",
|
72 | 74 | "AZURE_AI_API_VERSION = os.getenv(\"AZURE_AI_API_VERSION\", \"2025-05-01-preview\")\n",
|
73 | 75 | "\n",
|
74 |
| - "# Add the parent directory to the path to use shared modules \n", |
| 76 | + "# Add the parent directory to the system path to use shared modules\n", |
75 | 77 | "parent_dir = Path(Path.cwd()).parent\n",
|
76 | 78 | "sys.path.append(str(parent_dir))\n",
|
77 | 79 | "from python.content_understanding_client import AzureContentUnderstandingClient\n",
|
|
84 | 86 | " api_version=AZURE_AI_API_VERSION,\n",
|
85 | 87 | " # IMPORTANT: Comment out token_provider if using subscription key\n",
|
86 | 88 | " token_provider=token_provider,\n",
|
87 |
| - " # IMPORTANT: Uncomment this if using subscription key\n", |
| 89 | + " # IMPORTANT: Uncomment this line if using subscription key\n", |
88 | 90 | " # subscription_key=AZURE_AI_API_KEY,\n",
|
89 |
| - " x_ms_useragent=\"azure-ai-content-understanding-python/analyzer_management\", # This header is used for sample usage telemetry, please comment out this line if you want to opt out.\n", |
| 91 | + " x_ms_useragent=\"azure-ai-content-understanding-python/analyzer_management\", # This header is used for sample usage telemetry. Please comment out this line if you want to opt out.\n", |
90 | 92 | ")"
|
91 | 93 | ]
|
92 | 94 | },
|
93 | 95 | {
|
94 | 96 | "cell_type": "markdown",
|
95 | 97 | "metadata": {},
|
96 | 98 | "source": [
|
97 |
| - "## Create a simple analyzer\n", |
98 |
| - "We first create an analyzer from a template to extract invoice fields." |
| 99 | + "## Create a Simple Analyzer\n", |
| 100 | + "First, we create an analyzer from a template to extract invoice fields." |
99 | 101 | ]
|
100 | 102 | },
|
101 | 103 | {
|
|
119 | 121 | "cell_type": "markdown",
|
120 | 122 | "metadata": {},
|
121 | 123 | "source": [
|
122 |
| - "## List all analyzers created in your resource" |
| 124 | + "## List All Analyzers in Your Resource" |
123 | 125 | ]
|
124 | 126 | },
|
125 | 127 | {
|
126 | 128 | "cell_type": "markdown",
|
127 | 129 | "metadata": {},
|
128 | 130 | "source": [
|
129 |
| - "After the analyzer is successfully created, we can use it to analyze our input files." |
| 131 | + "After successfully creating an analyzer, you can use it to analyze our input files. You can also list all analyzers available in your resource." |
130 | 132 | ]
|
131 | 133 | },
|
132 | 134 | {
|
|
137 | 139 | "source": [
|
138 | 140 | "response = client.get_all_analyzers()\n",
|
139 | 141 | "print(f\"Number of analyzers in your resource: {len(response['value'])}\")\n",
|
140 |
| - "print(f\"The first 3 analyzer details: {json.dumps(response['value'][:3], indent=2)}\")\n", |
141 |
| - "print(f\"The last analyzer details: {json.dumps(response['value'][:-1], indent=2)}\")" |
| 142 | + "print(f\"Details of the first 3 analyzers: {json.dumps(response['value'][:3], indent=2)}\")\n", |
| 143 | + "print(f\"Details of the last analyzer: {json.dumps(response['value'][-1], indent=2)}\")" |
142 | 144 | ]
|
143 | 145 | },
|
144 | 146 | {
|
145 | 147 | "cell_type": "markdown",
|
146 | 148 | "metadata": {},
|
147 | 149 | "source": [
|
148 |
| - "## Get analyzer details with id\n", |
| 150 | + "## Get Analyzer Details by ID\n", |
149 | 151 | "\n",
|
150 |
| - "Remember the analyzer id when you create it. You can use the id to look up detail analyzer definitions afterwards." |
| 152 | + "Keep track of the analyzer ID when you create it. Use the ID to retrieve detailed analyzer definitions later." |
151 | 153 | ]
|
152 | 154 | },
|
153 | 155 | {
|
|
164 | 166 | "cell_type": "markdown",
|
165 | 167 | "metadata": {},
|
166 | 168 | "source": [
|
167 |
| - "## Delete Analyzer\n", |
168 |
| - "If you don't need an analyzer anymore, delete it with its id." |
| 169 | + "## Delete an Analyzer\n", |
| 170 | + "If you no longer need an analyzer, delete it using its ID." |
169 | 171 | ]
|
170 | 172 | },
|
171 | 173 | {
|
|
0 commit comments