99
1010SUBSCRIPTION_KEY_ENV_NAME = "LUIS_SUBSCRIPTION_KEY"
1111
12+
1213def booking_app (subscription_kuy ):
1314 """Authoring.
1415
@@ -24,7 +25,8 @@ def booking_app(subscription_kuy):
2425 default_app_name = "Contoso-{}" .format (datetime .datetime .now ())
2526 version_id = "0.1"
2627
27- print ("Creating App {}, version {}" .format (default_app_name , version_id ))
28+ print ("Creating App {}, version {}" .format (
29+ default_app_name , version_id ))
2830
2931 app_id = client .apps .add ({
3032 'name' : default_app_name ,
@@ -111,17 +113,21 @@ def get_example_label(utterance, entity_name, value):
111113 utterances = [{
112114 'text' : find_economy_to_madrid ,
113115 'intent_name' : intent_name ,
114- 'entity_labels' :[
115- get_example_label (find_economy_to_madrid , "Flight" , "economy to madrid" ),
116- get_example_label (find_economy_to_madrid , "Destination" , "Madrid" ),
116+ 'entity_labels' : [
117+ get_example_label (find_economy_to_madrid ,
118+ "Flight" , "economy to madrid" ),
119+ get_example_label (find_economy_to_madrid ,
120+ "Destination" , "Madrid" ),
117121 get_example_label (find_economy_to_madrid , "Class" , "economy" ),
118122 ]
119123 }, {
120124 'text' : find_first_to_london ,
121125 'intent_name' : intent_name ,
122- 'entity_labels' :[
123- get_example_label (find_first_to_london , "Flight" , "London in first class" ),
124- get_example_label (find_first_to_london , "Destination" , "London" ),
126+ 'entity_labels' : [
127+ get_example_label (find_first_to_london ,
128+ "Flight" , "London in first class" ),
129+ get_example_label (find_first_to_london ,
130+ "Destination" , "London" ),
125131 get_example_label (find_first_to_london , "Class" , "first" ),
126132 ]
127133 }]
@@ -143,7 +149,8 @@ def get_example_label(utterance, entity_name, value):
143149 while not is_trained :
144150 time .sleep (1 )
145151 status = client .train .get_status (app_id , version_id )
146- is_trained = all (m .details .status in trained_status for m in status )
152+ is_trained = all (
153+ m .details .status in trained_status for m in status )
147154
148155 print ("Your app is trained. You can now go to the LUIS portal and test it!" )
149156
@@ -158,12 +165,14 @@ def get_example_label(utterance, entity_name, value):
158165 'region' : 'westus'
159166 }
160167 )
161- endpoint = publish_result .endpoint_url + "?subscription-key=" + subscription_key + "&q="
168+ endpoint = publish_result .endpoint_url + \
169+ "?subscription-key=" + subscription_key + "&q="
162170 print ("Your app is published. You can now go to test it on\n {}" .format (endpoint ))
163171
164172 except Exception as err :
165173 print ("Encountered exception. {}" .format (err ))
166174
175+
167176def management (subscription_key ):
168177 """Managing
169178
@@ -179,7 +188,8 @@ def management(subscription_key):
179188 default_app_name = "Contoso-{}" .format (datetime .datetime .now ())
180189 version_id = "0.1"
181190
182- print ("Creating App {}, version {}" .format (default_app_name , version_id ))
191+ print ("Creating App {}, version {}" .format (
192+ default_app_name , version_id ))
183193
184194 app_id = client .apps .add ({
185195 'name' : default_app_name ,
@@ -224,17 +234,20 @@ def management(subscription_key):
224234 # Listing versions
225235 print ("\n List all versions in this app" )
226236 for version in client .versions .list (app_id ):
227- print ("\t ->Version: '{}', training status: {}" .format (version .version , version .training_status ))
237+ print ("\t ->Version: '{}', training status: {}" .format (version .version ,
238+ version .training_status ))
228239
229240 # Print app details
230241 print ("\n Print app '{}' details" .format (default_app_name ))
231242 details = client .apps .get (app_id )
232- pprint (details .as_dict ()) # as_dict "dictify" the object, by default it's attribute based. e.g. details.name
243+ # as_dict "dictify" the object, by default it's attribute based. e.g. details.name
244+ pprint (details .as_dict ())
233245
234246 # Print version details
235247 print ("\n Print version '{}' details" .format (version_id ))
236248 details = client .versions .get (app_id , version_id )
237- pprint (details .as_dict ()) # as_dict "dictify" the object, by default it's attribute based. e.g. details.name
249+ # as_dict "dictify" the object, by default it's attribute based. e.g. details.name
250+ pprint (details .as_dict ())
238251
239252 # Delete an app
240253 print ("\n Delete app '{}'" .format (default_app_name ))
@@ -244,8 +257,10 @@ def management(subscription_key):
244257 except Exception as err :
245258 print ("Encountered exception. {}" .format (err ))
246259
260+
247261if __name__ == "__main__" :
248- import sys , os .path
262+ import sys
263+ import os .path
249264 sys .path .append (os .path .abspath (os .path .join (__file__ , ".." , ".." )))
250265 from tools import execute_samples
251266 execute_samples (globals (), SUBSCRIPTION_KEY_ENV_NAME )
0 commit comments