-
Notifications
You must be signed in to change notification settings - Fork 5
/
RequestHandler.py
47 lines (36 loc) · 1.38 KB
/
RequestHandler.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# -*- coding: utf-8 -*-
class RequestHandler():
def __init__(self):
pass
def getResult(self, sentence):
"""1. Complete the classification in this function.
Args:
sentence: A string of sentence.
Returns:
classification: A string of the result of classification.
"""
return "chat"
def getBatchResults(self, sentencesList):
"""2. You can also complete the classification in this function,
if you want to classify the sentences in batch.
Args:
sentencesList: A List of Dictionaries of ids and sentences,
like:
[{'id':331, 'content':'帮我打电话给张三' },
{'id':332, 'content':'帮我订一张机票!' },
... ]
Returns:
resultsList: A List of Dictionaries of ids and results.
The order of the list must be the same as the input list,
like:
[{'id':331, 'result':'telephone' },
{'id':332, 'result':'flight' },
... ]
"""
resultsList = []
for sentence in sentencesList:
resultDict = {}
resultDict['id'] = sentence['id']
resultDict['result'] = self.getResult(sentence['content'])
resultsList.append(resultDict)
return resultsList