Skip to content

Commit 698b605

Browse files
authored
Merge pull request #2864 from MicrosoftDocs/repo_sync_working_branch
Confirm merge from repo_sync_working_branch to main to sync with https://github.com/MicrosoftDocs/azure-ai-docs (branch main)
2 parents 8e52cb8 + 4a8ea5e commit 698b605

File tree

2 files changed

+12
-8
lines changed
  • articles/ai-services
    • document-intelligence/quickstarts/includes
    • translator/document-translation/quickstarts/includes/sdk

2 files changed

+12
-8
lines changed

articles/ai-services/document-intelligence/quickstarts/includes/csharp-sdk.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -678,15 +678,15 @@ for (int i = 0; i < result.Documents.Count; i++)
678678
}
679679

680680
if (document.Fields.TryGetValue("Items", out DocumentField itemsField)
681-
&& itemsField.Type == DocumentFieldType.Array)
681+
&& itemsField.Type == DocumentFieldType.List)
682682
{
683-
foreach (DocumentField itemField in itemsField.ValueArray)
683+
foreach (DocumentField itemField in itemsField.ValueList)
684684
{
685685
Console.WriteLine("Item:");
686686

687-
if (itemField.Type == DocumentFieldType.Object)
687+
if (itemField.Type == DocumentFieldType.Dictionary)
688688
{
689-
IReadOnlyDictionary<string, DocumentField> itemFields = itemField.ValueObject;
689+
IReadOnlyDictionary<string, DocumentField> itemFields = itemField.ValueDictionary;
690690

691691
if (itemFields.TryGetValue("Description", out DocumentField itemDescriptionField)
692692
&& itemDescriptionField.Type == DocumentFieldType.String)

articles/ai-services/translator/document-translation/quickstarts/includes/sdk/python.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,13 @@ def sample_single_document_translation():
153153

154154
# absolute path to your document
155155
file_path = "C:/{your-file-path}/document-translation-sample.docx"
156-
file_name = os.path.path.basename(file_path)
156+
file_name = os.path.basename(file_path)
157157
file_type = (
158158
"application/vnd.openxmlformats-officedocument.wordprocessingml.document"
159159
)
160160
print(f"File for translation: {file_name}")
161161

162-
with open(file_name, "r") as file:
162+
with open(file_path, "rb") as file:
163163
file_contents = file.read()
164164

165165
document_content = (file_name, file_contents, file_type)
@@ -168,8 +168,12 @@ def sample_single_document_translation():
168168
response_stream = client.document_translate(
169169
body=document_translate_content, target_language=target_language
170170
)
171-
translated_response = response_stream.decode("utf-8-sig") # type: ignore[attr-defined]
172-
print(f"Translated response: {translated_response}")
171+
# Save the response_stream to a file
172+
output_file_path = "./translated-document.docx"
173+
with open(output_file_path, "wb") as output_file:
174+
output_file.write(response_stream)
175+
176+
print(f"Translated document saved to: {output_file_path}")
173177

174178

175179
if __name__ == "__main__":

0 commit comments

Comments
 (0)