Skip to content

Commit d5cc71f

Browse files
committed
add test data for chatbot
1 parent 6225038 commit d5cc71f

File tree

2 files changed

+914
-31
lines changed

2 files changed

+914
-31
lines changed

chap20_hoayi_api_guide/05.chatbot/chatbot_test_api.ipynb

Lines changed: 85 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
{
1111
"cell_type": "code",
12-
"execution_count": 141,
12+
"execution_count": 232,
1313
"metadata": {
1414
"collapsed": false
1515
},
@@ -18,23 +18,30 @@
1818
"name": "stdout",
1919
"output_type": "stream",
2020
"text": [
21-
"b7b7dc1fff64:8000\n",
22-
"{'story_ner_entity': [{'val': ['김승우', '김승우'], 'key': 'tagname'}], 'story_slot_entity': [{'val': ['화성부'], 'key': '9415774b-5fba-11e7-a2c2-4562a502e279'}, {'val': ['광양'], 'key': 'b3d891c6-5fba-11e7-a2c2-4562a502e279'}, {'val': ['김승우'], 'key': '83e9256c-5fba-11e7-a2c2-4562a502e279'}], 'story_key_entity': [], 'morphed_data': ['(', '광양', ')', '화성부', '김승우'], 'input_data': '(광양)화성부 김승우', 'convert_dict_data': ['(', 'tagloc', ')', 'tagorg', 'tagname'], 'output_data': '', 'convert_data': ['tagorg', 'tagname'], 'test_intent_id': ['8'], 'intent_id': ['c3041cd0-5d46-11e7-a7ce-f53d67ca25aa'], 'pattern_intent_id': ['8'], 'test_slot_entity': [{'val': ['화성부'], 'key': 'tagorg'}, {'val': ['광양'], 'key': 'tagloc'}, {'val': ['김승우'], 'key': 'tagname'}], 'request_type': 'text', 'service_type': 'I', 'story_board_id': '', 'intent_history': ['', {'P': '8'}, {'i': '8'}], 'edit_history': []}\n",
23-
"1. 입력문장: (광양)화성부 김승우\n",
24-
"2. 분석의도: ['8']\n",
25-
"3. 분석Entity: [{'val': ['화성부'], 'key': 'tagorg'}, {'val': ['광양'], 'key': 'tagloc'}, {'val': ['김승우'], 'key': 'tagname'}]\n"
21+
"{\"result\": \"'NoneType' object has no attribute '__dict__'\", \"status\": \"404\"}\n"
22+
]
23+
},
24+
{
25+
"ename": "TypeError",
26+
"evalue": "string indices must be integers",
27+
"output_type": "error",
28+
"traceback": [
29+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
30+
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
31+
"\u001b[0;32m<ipython-input-232-d97a1a2ffc10>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 18\u001b[0m })\n\u001b[1;32m 19\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mresp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mjson\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 20\u001b[0;31m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"1. 입력문장: {0}\"\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mformat\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mresp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mjson\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'input_data'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 21\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"2. 분석의도: {0}\"\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mformat\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mresp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mjson\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'test_intent_id'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 22\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"3. 분석Entity: {0}\"\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mformat\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mresp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mjson\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'test_slot_entity'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
32+
"\u001b[0;31mTypeError\u001b[0m: string indices must be integers"
2633
]
2734
}
2835
],
2936
"source": [
3037
"#-*- coding: utf-8 -*-\n",
3138
"import requests\n",
3239
"import json, os\n",
33-
"url = \"UNKNOWN\"\n",
40+
"url = \"{0}:{1}\".format(os.environ['HOSTNAME'] , \"8000\")\n",
3441
"resp = requests.put('http://' + url + '/api/v1/type/service/chatbot/cb0001/', \n",
3542
" json={ \"intent_id\" : \"\",\n",
3643
" \"edit_history\" : [],\n",
37-
" \"input_data\": \"(광양)화성부 김승우\",\n",
44+
" \"input_data\": \"김수상 a근태\",\n",
3845
" \"convert_data\" : \"\",\n",
3946
" \"intent_history\" : [],\n",
4047
" \"request_type\" : \"text\",\n",
@@ -59,7 +66,7 @@
5966
},
6067
{
6168
"cell_type": "code",
62-
"execution_count": 176,
69+
"execution_count": 222,
6370
"metadata": {
6471
"collapsed": false
6572
},
@@ -113,7 +120,7 @@
113120
" \n",
114121
" def __init__(self) : \n",
115122
" self.thread_num = 3 \n",
116-
" self.url = \"UNKNOWN\"\n",
123+
" self.url = \"\"\n",
117124
" self.cb_id = 'cb0001'\n",
118125
" self.result = {}\n",
119126
" self.result['labels'] = ['-1','1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16']\n",
@@ -167,7 +174,7 @@
167174
},
168175
{
169176
"cell_type": "code",
170-
"execution_count": 177,
177+
"execution_count": 230,
171178
"metadata": {
172179
"collapsed": false
173180
},
@@ -176,30 +183,77 @@
176183
"name": "stdout",
177184
"output_type": "stream",
178185
"text": [
179-
"Intent Unmatch: 화학시험섹션 김수상 찾아줘\n",
180-
"Entity Unmatch : 포항의 경영지원팀장 찾아줘\n",
181-
"Intent Unmatch: 포항의 화학시험팀장 찾아줘\n",
182-
"Entity Unmatch : 포항의 화학시험팀장 찾아줘\n",
183-
"Intent Unmatch: 김수상 차장의 사업부장\n",
184-
"Entity Unmatch : 경영지원본부장 전화\n"
186+
"Intent Unmatch: 행정담당 부소장\n",
187+
"Entity Unmatch : 행정담당 부소장\n",
188+
"Intent Unmatch: 법무실 법무위원\n",
189+
"Entity Unmatch : 법무실 법무위원\n",
190+
"Intent Unmatch: 광양제철소 행정담당 부소장\n",
191+
"Entity Unmatch : 광양제철소 행정담당 부소장\n",
192+
"Intent Unmatch: POSCO Japan PC 일본 법인장\n",
193+
"Entity Unmatch : POSCO Japan PC 일본 법인장\n",
194+
"Intent Unmatch: POSCO SS VINA PC 베트남 법인장\n",
195+
"Entity Unmatch : POSCO SS VINA PC 베트남 법인장\n",
196+
"Intent Unmatch: POSCO Thainox PC 태국 법인장\n",
197+
"Entity Unmatch : POSCO Thainox PC 태국 법인장\n",
198+
"Intent Unmatch: 광동순덕버빈장\n",
199+
"Entity Unmatch : 광동순덕버빈장\n",
200+
"Entity Unmatch : 차이나부법인장\n",
201+
"Entity Unmatch : CSPC법인장\n"
185202
]
186203
}
187204
],
188205
"source": [
189-
"test_data = [{\"input\" : \"오늘 김수상 휴가\", \"intent\":\"5\",\"slot\":[\"tagname\"]},\n",
190-
" {\"input\" : \"화학시험섹션 김수상 찾아줘\", \"intent\":\"9\",\"slot\":[\"tagname\"]},\n",
191-
" {\"input\" : \"포항의 경영지원팀장 찾아줘\", \"intent\":\"1\",\"slot\":[\"tagname\"]},\n",
192-
" {\"input\" : \"포항의 화학시험팀장 찾아줘\", \"intent\":\"1\",\"slot\":[\"tagname\"]},\n",
193-
" {\"input\" : \"김수상의 팀장\", \"intent\":\"2\",\"slot\":[\"tagname\"]},\n",
194-
" {\"input\" : \"김수상 부장의 팀장\", \"intent\":\"2\",\"slot\":[\"tagname\"]},\n",
195-
" {\"input\" : \"김수상 차장의 사업부장\", \"intent\":\"2\",\"slot\":[\"tagname\"]},\n",
196-
" {\"input\" : \"김수상 휴가인가\", \"intent\":\"5\",\"slot\":[\"tagname\"]},\n",
197-
" {\"input\" : \"김수상 오늘 근태\", \"intent\":\"5\",\"slot\":[\"tagname\"]},\n",
198-
" {\"input\" : \"김수상 부장 오늘 출장\", \"intent\":\"5\",\"slot\":[\"tagname\"]},\n",
199-
" {\"input\" : \"김수상 부장 오늘 해외 출장\", \"intent\":\"5\",\"slot\":[\"tagname\"]},\n",
200-
" {\"input\" : \"오늘 김수상 휴가\", \"intent\":\"5\",\"slot\":[\"tagname\"]},\n",
201-
" {\"input\" : \"김수상 부장 오늘 해외 출장\", \"intent\":\"5\",\"slot\":[\"tagname\"]},\n",
202-
" {\"input\" : \"경영지원본부장 전화\", \"intent\":\"3\",\"slot\":[\"tagname\"]},\n",
206+
"test_data = [\n",
207+
" {\"input\" : \"오늘 김수상 휴가\", \"intent\":\"5\",\"slot\":[\"tagname\"]},\n",
208+
" {\"input\" : \"화학시험섹션 김수상 찾아줘\", \"intent\":\"8\",\"slot\":[\"tagname\"]},\n",
209+
" {\"input\" : \"포항의 경영지원팀장 찾아줘\", \"intent\":\"1\",\"slot\":[\"tagloc\",\"tagrank\"]},\n",
210+
" {\"input\" : \"김수상의 팀장\", \"intent\":\"2\",\"slot\":[\"tagname\"]},\n",
211+
" {\"input\" : \"김수상 부장의 팀장\", \"intent\":\"2\",\"slot\":[\"tagname\"]},\n",
212+
" {\"input\" : \"김수상 차장의 사업부장\", \"intent\":\"2\",\"slot\":[\"tagname\",\"tagrank\",\"tagsuper\"]},\n",
213+
" {\"input\" : \"김수상 휴가인가\", \"intent\":\"5\",\"slot\":[\"tagname\"]},\n",
214+
" {\"input\" : \"김수상 오늘 근태\", \"intent\":\"5\",\"slot\":[\"tagname\"]},\n",
215+
" {\"input\" : \"김수상 부장 오늘 출장\", \"intent\":\"5\",\"slot\":[\"tagname\"]},\n",
216+
" {\"input\" : \"김수상 부장 오늘 해외 출장\", \"intent\":\"5\",\"slot\":[\"tagname\"]},\n",
217+
" {\"input\" : \"오늘 김수상 휴가\", \"intent\":\"5\",\"slot\":[\"tagname\"]},\n",
218+
" {\"input\" : \"김수상 부장 오늘 해외 출장\", \"intent\":\"5\",\"slot\":[\"tagname\"]},\n",
219+
" {\"input\" : \"경영지원본부장 전화\", \"intent\":\"3\",\"slot\":[\"taghead\"]},\n",
220+
" {\"input\" : \"광양제철소장 전화\", \"intent\":\"3\",\"slot\":[\"taghead\"]},\n",
221+
" {\"input\" : \"인니법인장 전화\", \"intent\":\"3\",\"slot\":[\"taghead\"]},\n",
222+
" {\"input\" : \"행정담당 부소장 전화\", \"intent\":\"3\",\"slot\":[\"taghead\"]},\n",
223+
" {\"input\" : \"정도경영실장 전화\", \"intent\":\"3\",\"slot\":[\"taghead\"]},\n",
224+
" {\"input\" : \"법무실 법무위원 전화\", \"intent\":\"3\",\"slot\":[\"taghead\"]},\n",
225+
" {\"input\" : \"광양제철소 행정담당 부소장 전화\", \"intent\":\"3\",\"slot\":[\"taghead\"]},\n",
226+
" {\"input\" : \"ER실장 전화\", \"intent\":\"3\",\"slot\":[\"taghead\"]},\n",
227+
" {\"input\" : \"경영지원본부장\", \"intent\":\"7\",\"slot\":[\"taghead\"]},\n",
228+
" {\"input\" : \"광양제철소장\", \"intent\":\"7\",\"slot\":[\"taghead\"]},\n",
229+
" {\"input\" : \"인니법인장\", \"intent\":\"7\",\"slot\":[\"taghead\"]},\n",
230+
" {\"input\" : \"행정담당 부소장\", \"intent\":\"7\",\"slot\":[\"taghead\"]},\n",
231+
" {\"input\" : \"정도경영실장\", \"intent\":\"7\",\"slot\":[\"taghead\"]},\n",
232+
" {\"input\" : \"법무실 법무위원\", \"intent\":\"7\",\"slot\":[\"taghead\"]},\n",
233+
" {\"input\" : \"광양제철소 행정담당 부소장\", \"intent\":\"7\",\"slot\":[\"taghead\"]},\n",
234+
" {\"input\" : \"ER실장\", \"intent\":\"7\",\"slot\":[\"taghead\"]},\n",
235+
" {\"input\" : \"김수상에 전화걸어\", \"intent\":\"4\",\"slot\":[\"tagname\"]},\n",
236+
" {\"input\" : \"김수상에 전화걸어\", \"intent\":\"4\",\"slot\":[\"tagname\"]},\n",
237+
" {\"input\" : \"김수상 과장에 전화걸어\", \"intent\":\"4\",\"slot\":[\"tagname\"]},\n",
238+
" {\"input\" : \"김수상 부장에 전화걸어\", \"intent\":\"4\",\"slot\":[\"tagname\"]},\n",
239+
" {\"input\" : \"김수상 사업부장에 전화걸어\", \"intent\":\"4\",\"slot\":[\"tagname\"]},\n",
240+
" {\"input\" : \"김수상에 전화\", \"intent\":\"4\",\"slot\":[\"tagname\"]},\n",
241+
" {\"input\" : \"김수상에 연락\", \"intent\":\"4\",\"slot\":[\"tagname\"]},\n",
242+
" {\"input\" : \"POSCO Japan PC 일본 법인장\", \"intent\":\"6\",\"slot\":[\"tagnceo\"]},\n",
243+
" {\"input\" : \"POSCO SS VINA PC 베트남 법인장\", \"intent\":\"6\",\"slot\":[\"tagnceo\"]},\n",
244+
" {\"input\" : \"POSCO Thainox PC 태국 법인장\", \"intent\":\"6\",\"slot\":[\"tagnceo\"]},\n",
245+
" {\"input\" : \"광동순덕버빈장\", \"intent\":\"6\",\"slot\":[\"tagnceo\"]},\n",
246+
" {\"input\" : \"차이나부법인장\", \"intent\":\"6\",\"slot\":[\"tagnceo\"]},\n",
247+
" {\"input\" : \"CSPC법인장\", \"intent\":\"6\",\"slot\":[\"tagnceo\"]},\n",
248+
" {\"input\" : \"차민주 찾아줘\", \"intent\":\"8\",\"slot\":[\"tagname\"]},\n",
249+
" {\"input\" : \"차민주 부장 찾아줘\", \"intent\":\"8\",\"slot\":[\"tagname\",\"tagrank\"]},\n",
250+
" {\"input\" : \"차민주 부장 검색\", \"intent\":\"8\",\"slot\":[\"tagname\",\"tagrank\"]},\n",
251+
" {\"input\" : \"광양 차민주 찾아줘\", \"intent\":\"8\",\"slot\":[\"tagname\",\"tagloc\"]},\n",
252+
" {\"input\" : \"안전환경기술섹션 차민주 찾아줘\", \"intent\":\"8\",\"slot\":[\"tagname\",\"tagorg\"]},\n",
253+
" {\"input\" : \"냉연부 차민주 찾아줘\", \"intent\":\"8\",\"slot\":[\"tagname\",\"tagorg\"]},\n",
254+
" {\"input\" : \"1도금공장 차민주 찾아줘\", \"intent\":\"8\",\"slot\":[\"tagname\",\"tagorg\"]},\n",
255+
" {\"input\" : \"가공공장 차민주 찾아줘\", \"intent\":\"8\",\"slot\":[\"tagname\",\"tagorg\"]},\n",
256+
" {\"input\" : \"PJT지원섹션 차민주 찾아줘\", \"intent\":\"8\",\"slot\":[\"tagname\",\"tagorg\"]}\n",
203257
" ]\n",
204258
"testCls = ChatBotTest()\n",
205259
"testCls.run_test(test_data)\n",

0 commit comments

Comments
 (0)