-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsentence.py
43 lines (34 loc) · 904 Bytes
/
sentence.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
# -*- coding: utf8 -*-
from Model import Model
class sentence:
@staticmethod
def loadByCharacterIdAndTriggerWord(idCharacter, triggerWord):
sentences = list()
sentencesModels = model.loadByCharacterIdAndTriggerWord(
idCharacter, triggerWord
)
for index, s in enumerate(sentencesModels):
sentences.append(sentence())
sentences[index]._model = s
return sentences
def getSentence(self):
return self._model['sentence']
class model(Model):
@staticmethod
def loadByCharacterIdAndTriggerWord(idCharacter, triggerWord):
query = "\
SELECT\
ta.id_talk_answer,\
trigger_word,\
sentence,\
condition\
FROM\
talk_answer ta\
INNER JOIN character_answer ca\
ON ca.id_talk_answer = ta.id_talk_answer\
WHERE\
trigger_word = ?\
AND id_character = ?\
ORDER BY RANDOM()\
"
return Model.fetchAllRows(query, (triggerWord, idCharacter))