Skip to content

Commit e91766e

Browse files
authored
[cognitive-language] Modernized strings (Azure#25884)
* feat: modernize strings in QA * format methods to f-strings * remove unicode strings * feat: modernize strings * Replaced format method with f-strings * Removed unicode strings * Revert "feat: modernize strings in QA" This reverts commit b4a0e7a. * Revert changes to generated files * fix: revert _vendor.py files * oops, missed some!
1 parent 6f9d005 commit e91766e

18 files changed

+177
-177
lines changed

sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/_patch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ def _authentication_policy(credential):
4444
)
4545
elif credential is not None and not hasattr(credential, "get_token"):
4646
raise TypeError(
47-
"Unsupported credential: {}. Use an instance of AzureKeyCredential "
48-
"or a token credential from azure.identity".format(type(credential))
47+
f"Unsupported credential: {type(credential)}. Use an instance of AzureKeyCredential "
48+
"or a token credential from azure.identity"
4949
)
5050
return authentication_policy
5151

sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/aio/_patch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ def _authentication_policy(credential):
4545
)
4646
elif credential is not None and not hasattr(credential, "get_token"):
4747
raise TypeError(
48-
"Unsupported credential: {}. Use an instance of AzureKeyCredential "
49-
"or a token credential from azure.identity".format(type(credential))
48+
f"Unsupported credential: {type(credential)}. Use an instance of AzureKeyCredential "
49+
"or a token credential from azure.identity"
5050
)
5151
return authentication_policy
5252

sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/_patch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ def _authentication_policy(credential):
2222
)
2323
elif credential is not None and not hasattr(credential, "get_token"):
2424
raise TypeError(
25-
"Unsupported credential: {}. Use an instance of AzureKeyCredential "
26-
"or a token credential from azure.identity".format(type(credential))
25+
f"Unsupported credential: {type(credential)}. Use an instance of AzureKeyCredential "
26+
"or a token credential from azure.identity"
2727
)
2828
return authentication_policy
2929

sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/aio/_patch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ def _authentication_policy(credential):
2323
)
2424
elif credential is not None and not hasattr(credential, "get_token"):
2525
raise TypeError(
26-
"Unsupported credential: {}. Use an instance of AzureKeyCredential "
27-
"or a token credential from azure.identity".format(type(credential))
26+
f"Unsupported credential: {type(credential)}. Use an instance of AzureKeyCredential "
27+
"or a token credential from azure.identity"
2828
)
2929
return authentication_policy
3030

sdk/cognitivelanguage/azure-ai-language-conversations/samples/async/sample_analyze_conversation_app_async.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -64,31 +64,31 @@ async def sample_analyze_conversation_app_async():
6464
)
6565

6666
# view result
67-
print("query: {}".format(result["result"]["query"]))
68-
print("project kind: {}\n".format(result["result"]["prediction"]["projectKind"]))
67+
print(f"query: {result['result']['query']}")
68+
print(f"project kind: {result['result']['prediction']['projectKind']}\n")
6969

70-
print("top intent: {}".format(result["result"]["prediction"]["topIntent"]))
71-
print("category: {}".format(result["result"]["prediction"]["intents"][0]["category"]))
72-
print("confidence score: {}\n".format(result["result"]["prediction"]["intents"][0]["confidenceScore"]))
70+
print(f"top intent: {result['result']['prediction']['topIntent']}")
71+
print(f"category: {result['result']['prediction']['intents'][0]['category']}")
72+
print(f"confidence score: {result['result']['prediction']['intents'][0]['confidenceScore']}\n")
7373

7474
print("entities:")
75-
for entity in result["result"]["prediction"]["entities"]:
76-
print("\ncategory: {}".format(entity["category"]))
77-
print("text: {}".format(entity["text"]))
78-
print("confidence score: {}".format(entity["confidenceScore"]))
75+
for entity in result['result']['prediction']['entities']:
76+
print(f"\ncategory: {entity['category']}")
77+
print(f"text: {entity['text']}")
78+
print(f"confidence score: {entity['confidenceScore']}")
7979
if "resolutions" in entity:
8080
print("resolutions")
81-
for resolution in entity["resolutions"]:
82-
print("kind: {}".format(resolution["resolutionKind"]))
83-
print("value: {}".format(resolution["value"]))
81+
for resolution in entity['resolutions']:
82+
print(f"kind: {resolution['resolutionKind']}")
83+
print(f"value: {resolution['value']}")
8484
if "extraInformation" in entity:
8585
print("extra info")
86-
for data in entity["extraInformation"]:
87-
print("kind: {}".format(data["extraInformationKind"]))
88-
if data["extraInformationKind"] == "ListKey":
89-
print("key: {}".format(data["key"]))
90-
if data["extraInformationKind"] == "EntitySubtype":
91-
print("value: {}".format(data["value"]))
86+
for data in entity['extraInformation']:
87+
print(f"kind: {data['extraInformationKind']}")
88+
if data['extraInformationKind'] == "ListKey":
89+
print(f"key: {data['key']}")
90+
if data['extraInformationKind'] == "EntitySubtype":
91+
print(f"value: {data['value']}")
9292

9393
# [END analyze_conversation_app]
9494

@@ -98,4 +98,4 @@ async def main():
9898

9999
if __name__ == '__main__':
100100
loop = asyncio.get_event_loop()
101-
loop.run_until_complete(main())
101+
loop.run_until_complete(main())

sdk/cognitivelanguage/azure-ai-language-conversations/samples/async/sample_analyze_orchestration_app_conv_response_async.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -64,42 +64,42 @@ async def sample_analyze_orchestration_app_conv_response_async():
6464
)
6565

6666
# view result
67-
print("query: {}".format(result["result"]["query"]))
68-
print("project kind: {}\n".format(result["result"]["prediction"]["projectKind"]))
67+
print(f"query: {result['result']['query']}")
68+
print(f"project kind: {result['result']['prediction']['projectKind']}\n")
6969

7070
# top intent
71-
top_intent = result["result"]["prediction"]["topIntent"]
72-
print("top intent: {}".format(top_intent))
73-
top_intent_object = result["result"]["prediction"]["intents"][top_intent]
74-
print("confidence score: {}".format(top_intent_object["confidenceScore"]))
75-
print("project kind: {}".format(top_intent_object["targetProjectKind"]))
71+
top_intent = result['result']['prediction']['topIntent']
72+
print(f"top intent: {top_intent}")
73+
top_intent_object = result['result']['prediction']['intents'][top_intent]
74+
print(f"confidence score: {top_intent_object['confidenceScore']}")
75+
print(f"project kind: {top_intent_object['targetProjectKind']}")
7676

7777
# conversation result
78-
if top_intent_object["targetProjectKind"] == "Conversation":
78+
if top_intent_object['targetProjectKind'] == "Conversation":
7979
print("\nview conversation result:")
8080

81-
print("\ntop intent: {}".format(top_intent_object["result"]["prediction"]["topIntent"]))
82-
print("category: {}".format(top_intent_object["result"]["prediction"]["intents"][0]["category"]))
83-
print("confidence score: {}\n".format(top_intent_object["result"]["prediction"]["intents"][0]["confidenceScore"]))
81+
print(f"\ntop intent: {top_intent_object['result']['prediction']['topIntent']}")
82+
print(f"category: {top_intent_object['result']['prediction']['intents'][0]['category']}")
83+
print(f"confidence score: {top_intent_object['result']['prediction']['intents'][0]['confidenceScore']}\n")
8484

8585
print("\nview entities:")
86-
for entity in top_intent_object["result"]["prediction"]["entities"]:
87-
print("\ncategory: {}".format(entity["category"]))
88-
print("text: {}".format(entity["text"]))
89-
print("confidence score: {}".format(entity["confidenceScore"]))
86+
for entity in top_intent_object['result']['prediction']['entities']:
87+
print(f"\ncategory: {entity['category']}")
88+
print(f"text: {entity['text']}")
89+
print(f"confidence score: {entity['confidenceScore']}")
9090
if "resolutions" in entity:
9191
print("resolutions")
92-
for resolution in entity["resolutions"]:
93-
print("kind: {}".format(resolution["resolutionKind"]))
94-
print("value: {}".format(resolution["value"]))
92+
for resolution in entity['resolutions']:
93+
print(f"kind: {resolution['resolutionKind']}")
94+
print(f"value: {resolution['value']}")
9595
if "extraInformation" in entity:
9696
print("extra info")
97-
for data in entity["extraInformation"]:
98-
print("kind: {}".format(data["extraInformationKind"]))
99-
if data["extraInformationKind"] == "ListKey":
100-
print("key: {}".format(data["key"]))
101-
if data["extraInformationKind"] == "EntitySubtype":
102-
print("value: {}".format(data["value"]))
97+
for data in entity['extraInformation']:
98+
print(f"kind: {data['extraInformationKind']}")
99+
if data['extraInformationKind'] == "ListKey":
100+
print(f"key: {data['key']}")
101+
if data['extraInformationKind'] == "EntitySubtype":
102+
print(f"value: {data['value']}")
103103

104104
# [END analyze_orchestration_app_conv_response]
105105

@@ -108,4 +108,4 @@ async def main():
108108

109109
if __name__ == '__main__':
110110
loop = asyncio.get_event_loop()
111-
loop.run_until_complete(main())
111+
loop.run_until_complete(main())

sdk/cognitivelanguage/azure-ai-language-conversations/samples/async/sample_analyze_orchestration_app_luis_response_async.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,23 +64,23 @@ async def sample_analyze_orchestration_app_luis_response_async():
6464
)
6565

6666
# view result
67-
print("query: {}".format(result["result"]["query"]))
68-
print("project kind: {}\n".format(result["result"]["prediction"]["projectKind"]))
67+
print(f"query: {result['result']['query']}")
68+
print(f"project kind: {result['result']['prediction']['projectKind']}\n")
6969

7070
# top intent
71-
top_intent = result["result"]["prediction"]["topIntent"]
72-
print("top intent: {}".format(top_intent))
73-
top_intent_object = result["result"]["prediction"]["intents"][top_intent]
74-
print("confidence score: {}".format(top_intent_object["confidenceScore"]))
75-
print("project kind: {}".format(top_intent_object["targetProjectKind"]))
71+
top_intent = result['result']['prediction']['topIntent']
72+
print(f"top intent: {top_intent}")
73+
top_intent_object = result['result']['prediction']['intents'][top_intent]
74+
print(f"confidence score: {top_intent_object['confidenceScore']}")
75+
print(f"project kind: {top_intent_object['targetProjectKind']}")
7676

77-
if top_intent_object["targetProjectKind"] == "Luis":
77+
if top_intent_object['targetProjectKind'] == "Luis":
7878
print("\nluis response:")
79-
luis_response = top_intent_object["result"]["prediction"]
80-
print("top intent: {}".format(luis_response["topIntent"]))
79+
luis_response = top_intent_object['result']['prediction']
80+
print(f"top intent: {luis_response['topIntent']}")
8181
print("\nentities:")
82-
for entity in luis_response["entities"]:
83-
print("\n{}".format(entity))
82+
for entity in luis_response['entities']:
83+
print(f"\n{entity}")
8484

8585
# [END analyze_orchestration_app_luis_response]
8686

@@ -89,4 +89,4 @@ async def main():
8989

9090
if __name__ == '__main__':
9191
loop = asyncio.get_event_loop()
92-
loop.run_until_complete(main())
92+
loop.run_until_complete(main())

sdk/cognitivelanguage/azure-ai-language-conversations/samples/async/sample_analyze_orchestration_app_qna_response_async.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,22 +64,22 @@ async def sample_analyze_orchestration_app_qna_response_async():
6464
)
6565

6666
# view result
67-
print("query: {}".format(result["result"]["query"]))
68-
print("project kind: {}\n".format(result["result"]["prediction"]["projectKind"]))
67+
print(f"query: {result['result']['query']}")
68+
print(f"project kind: {result['result']['prediction']['projectKind']}\n")
6969

7070
# top intent
71-
top_intent = result["result"]["prediction"]["topIntent"]
72-
print("top intent: {}".format(top_intent))
73-
top_intent_object = result["result"]["prediction"]["intents"][top_intent]
74-
print("confidence score: {}".format(top_intent_object["confidenceScore"]))
75-
print("project kind: {}".format(top_intent_object["targetProjectKind"]))
71+
top_intent = result['result']['prediction']['topIntent']
72+
print(f"top intent: {top_intent}")
73+
top_intent_object = result['result']['prediction']['intents'][top_intent]
74+
print(f"confidence score: {top_intent_object['confidenceScore']}")
75+
print(f"project kind: {top_intent_object['targetProjectKind']}")
7676

77-
if top_intent_object["targetProjectKind"] == "QuestionAnswering":
77+
if top_intent_object['targetProjectKind'] == "QuestionAnswering":
7878
print("\nview qna result:")
79-
qna_result = top_intent_object["result"]
80-
for answer in qna_result["answers"]:
81-
print("\nanswer: {}".format(answer["answer"]))
82-
print("answer: {}".format(answer["confidenceScore"]))
79+
qna_result = top_intent_object['result']
80+
for answer in qna_result['answers']:
81+
print(f"\nanswer: {answer['answer']}")
82+
print(f"answer: {answer['confidenceScore']}")
8383

8484
# [END analyze_orchestration_app_qna_response]
8585

@@ -88,4 +88,4 @@ async def main():
8888

8989
if __name__ == '__main__':
9090
loop = asyncio.get_event_loop()
91-
loop.run_until_complete(main())
91+
loop.run_until_complete(main())

sdk/cognitivelanguage/azure-ai-language-conversations/samples/async/sample_analyze_orchestration_direct_target_async.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,22 +74,22 @@ async def sample_analyze_orchestration_direct_target_async():
7474
)
7575

7676
# view result
77-
print("query: {}".format(result["result"]["query"]))
78-
print("project kind: {}\n".format(result["result"]["prediction"]["projectKind"]))
77+
print(f"query: {result['result']['query']}")
78+
print(f"project kind: {result['result']['prediction']['projectKind']}\n")
7979

8080
# top intent
81-
top_intent = result["result"]["prediction"]["topIntent"]
82-
print("top intent: {}".format(top_intent))
83-
top_intent_object = result["result"]["prediction"]["intents"][top_intent]
84-
print("confidence score: {}".format(top_intent_object["confidenceScore"]))
85-
print("project kind: {}".format(top_intent_object["targetProjectKind"]))
81+
top_intent = result['result']['prediction']['topIntent']
82+
print(f"top intent: {top_intent}")
83+
top_intent_object = result['result']['prediction']['intents'][top_intent]
84+
print(f"confidence score: {top_intent_object['confidenceScore']}")
85+
print(f"project kind: {top_intent_object['targetProjectKind']}")
8686

87-
if top_intent_object["targetProjectKind"] == "QuestionAnswering":
87+
if top_intent_object['targetProjectKind'] == "QuestionAnswering":
8888
print("\nview qna result:")
89-
qna_result = top_intent_object["result"]
90-
for answer in qna_result["answers"]:
91-
print("\nanswer: {}".format(answer["answer"]))
92-
print("answer: {}".format(answer["confidenceScore"]))
89+
qna_result = top_intent_object['result']
90+
for answer in qna_result['answers']:
91+
print(f"\nanswer: {answer['answer']}")
92+
print(f"answer: {answer['confidenceScore']}")
9393

9494
# [END analyze_orchestration_app_qna_response]
9595

@@ -99,4 +99,4 @@ async def main():
9999

100100
if __name__ == '__main__':
101101
loop = asyncio.get_event_loop()
102-
loop.run_until_complete(main())
102+
loop.run_until_complete(main())

sdk/cognitivelanguage/azure-ai-language-conversations/samples/async/sample_conv_pii_transcript_input_async.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -95,31 +95,31 @@ async def sample_conv_pii_transcript_input_async():
9595

9696
# view result
9797
result = await poller.result()
98-
task_result = result["tasks"]["items"][0]
98+
task_result = result['tasks']['items'][0]
9999
print("... view task status ...")
100-
print("status: {}".format(task_result["status"]))
101-
conv_pii_result = task_result["results"]
102-
if conv_pii_result["errors"]:
100+
print(f"status: {task_result['status']}")
101+
conv_pii_result = task_result['results']
102+
if conv_pii_result['errors']:
103103
print("... errors occured ...")
104-
for error in conv_pii_result["errors"]:
104+
for error in conv_pii_result['errors']:
105105
print(error)
106106
else:
107-
conversation_result = conv_pii_result["conversations"][0]
108-
if conversation_result["warnings"]:
107+
conversation_result = conv_pii_result['conversations'][0]
108+
if conversation_result['warnings']:
109109
print("... view warnings ...")
110-
for warning in conversation_result["warnings"]:
110+
for warning in conversation_result['warnings']:
111111
print(warning)
112112
else:
113113
print("... view task result ...")
114-
for conversation in conversation_result["conversationItems"]:
115-
print("conversation id: {}".format(conversation["id"]))
114+
for conversation in conversation_result['conversationItems']:
115+
print(f"conversation id: {conversation['id']}")
116116
print("... entities ...")
117-
for entity in conversation["entities"]:
118-
print("text: {}".format(entity["text"]))
119-
print("category: {}".format(entity["category"]))
120-
print("confidence: {}".format(entity["confidenceScore"]))
121-
print("offset: {}".format(entity["offset"]))
122-
print("length: {}".format(entity["length"]))
117+
for entity in conversation['entities']:
118+
print(f"text: {entity['text']}")
119+
print(f"category: {entity['category']}")
120+
print(f"confidence: {entity['confidenceScore']}")
121+
print(f"offset: {entity['offset']}")
122+
print(f"length: {entity['length']}")
123123

124124

125125
# [END analyze_conversation_app]

0 commit comments

Comments
 (0)