区分订单状态追问与查货操作说明
This commit is contained in:
@@ -213,8 +213,13 @@ def build_card(row):
|
||||
|
||||
|
||||
def is_lookup_help(message):
|
||||
return bool(re.search(r'是什么意思|是什么|指什么|怎么(?:查|操作|使用)|如何(?:查|操作|使用)|怎样(?:查|操作|使用)|'
|
||||
r'\b(?:what\s+(?:is|are)|how\s+(?:do|can|to))\b', message, re.I))
|
||||
if re.search(r'是什么意思|指什么|怎么(?:查|操作|使用)|如何(?:查|操作|使用)|怎样(?:查|操作|使用)|'
|
||||
r'\bhow\s+(?:do|can|to)\b', message, re.I):
|
||||
return True
|
||||
if re.fullmatch(r'\s*(?:请问)?(?:物流轨迹|物流状态|订单状态|入仓码|入仓号)是什么[。?!?!\s]*', message):
|
||||
return True
|
||||
return bool(re.search(r'\bwhat\s+(?:is|are)\b', message, re.I) and
|
||||
not re.search(r'\b(?:my|this|that|our)\b', message, re.I))
|
||||
|
||||
|
||||
def is_tracking_request(message):
|
||||
@@ -226,7 +231,8 @@ def is_tracking_request(message):
|
||||
r'(?:现在|目前)?(?:到哪(?:里)?了?|什么时候(?:能|会)?到|何时能?到|多久能?到|'
|
||||
r'签收了?(?:吗|没)|状态|进度|轨迹)(?:呢|吗|呀|啊)?')
|
||||
english = (r'(?:where\s+(?:is|are)\s+my|track(?:\s+my)?|check(?:\s+my)?)\s+'
|
||||
r'(?:parcels?|packages?|shipments?|orders?)')
|
||||
r'(?:parcels?|packages?|shipments?|orders?)(?:\s+(?:status|progress))?|'
|
||||
r'what\s+is\s+my\s+(?:parcel|package|shipment|order)\s+(?:status|progress)')
|
||||
return bool(re.fullmatch(command+'|'+personal, question) or
|
||||
re.fullmatch(english, message.strip(' \t\r\n.!?'), re.I))
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ class CustomerTests(unittest.TestCase):
|
||||
def test_common_tracking_requests_require_login_without_calling_the_model(self):
|
||||
questions = ('查物流', '帮我查一下物流', '物流查询', '查货', '帮我查下轨迹',
|
||||
'我的货到哪了', '我的包裹到哪里了?', '这票货什么时候到?',
|
||||
'Where is my parcel?', 'Track my package')
|
||||
'Where is my parcel?', 'Track my package', 'What is my shipment status?')
|
||||
with patch('logistics_chat.ai_client.post_completion') as model:
|
||||
for question in questions:
|
||||
with self.subTest(question=question):
|
||||
|
||||
@@ -208,7 +208,8 @@ class OrderDataTests(unittest.TestCase):
|
||||
self.events(self.record['inbound_code'], cid)
|
||||
with patch('logistics_chat.ai_client.post_completion') as model:
|
||||
for question in ('查物流', '帮我查一下物流', '物流查询', '帮我查下轨迹', '查一下进度',
|
||||
'我的货到哪了', '这票货什么时候到?', 'Where is my parcel?'):
|
||||
'我的货到哪了', '这票货什么时候到?', '这票状态是什么?', '这个目的仓是什么?',
|
||||
'Where is my parcel?', 'What is my shipment status?'):
|
||||
with self.subTest(question=question):
|
||||
self.assertEqual(self.events(question, cid)[0]['card']['no'], self.record['order_no'])
|
||||
model.assert_not_called()
|
||||
@@ -216,7 +217,7 @@ class OrderDataTests(unittest.TestCase):
|
||||
db.save_message(cid, 'assistant', '海运费用与重量及目的地有关。')
|
||||
self.assertIn('请提供入仓码', self.events('查物流', cid)[0]['t'])
|
||||
for question in ('物流轨迹是什么意思?', '物流查询怎么操作?', '怎么查物流?',
|
||||
'海运一般多久到?', '包裹丢了怎么办?', 'What is parcel tracking?'):
|
||||
'海运一般多久到?', '包裹丢了怎么办?', 'What is parcel tracking?', '入仓码是什么?'):
|
||||
with self.subTest(general_question=question):
|
||||
self.assertIsNone(order_data.answer_query(question, None))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user