Skip to content

Commit

Permalink
Merge pull request #79 from Azure-Samples/aahill-patch-1
Browse files Browse the repository at this point in the history
Update text_analytics_samples.py
  • Loading branch information
aahill authored Dec 3, 2019
2 parents ecd4386 + 5647e4e commit a8cd58b
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions samples/language/text_analytics_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,20 @@
# </imports>

# <initialVars>
key = "<paste-your-text-analytics-key-here>"
endpoint = "<paste-your-text-analytics-endpoint-here>"
key_var_name = 'TEXT_ANALYTICS_SUBSCRIPTION_KEY'
if not key_var_name in os.environ:
raise Exception('Please set/export the environment variable: {}'.format(key_var_name))
subscription_key = os.environ[key_var_name]

endpoint_var_name = 'TEXT_ANALYTICS_ENDPOINT'
if not endpoint_var_name in os.environ:
raise Exception('Please set/export the environment variable: {}'.format(endpoint_var_name))
endpoint = os.environ[endpoint_var_name]
# </initialVars>

# <authentication>
def authenticateClient():
credentials = CognitiveServicesCredentials(key)
credentials = CognitiveServicesCredentials(subscription_key)
text_analytics_client = TextAnalyticsClient(
endpoint=endpoint, credentials=credentials)
return text_analytics_client
Expand Down

0 comments on commit a8cd58b

Please sign in to comment.