本文整理汇总了Python中Message.Message.addFeature方法的典型用法代码示例。如果您正苦于以下问题:Python Message.addFeature方法的具体用法?Python Message.addFeature怎么用?Python Message.addFeature使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Message.Message
的用法示例。
在下文中一共展示了Message.addFeature方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __loadMessagesFromEvents
# 需要导入模块: from Message import Message [as 别名]
# 或者: from Message.Message import addFeature [as 别名]
def __loadMessagesFromEvents(self):
"""Create an array of events from the user's event array.
Keyword arguments:
nope.
Return values:
messages -- array containing each event, in chronological order
messageLookupTables -- assoc array of 'event type' => array. Each array contains
indexes into messages array to rapidly retrieve all messages of that type (sent/unsent)
"""
messages = []
messageLookupTables = {}
messageLookupTables['sent'] = []
messageLookupTables['unsent'] = []
lastSnd = self.events[0].timestampAsDatetime;
messageEvents = []
messageDone = False
#remove:
print self.username
for event in self.events:
#if the event is a send, the current message has no more events
#or if the text box wasn't empty, and now is, samesies
if (event.type == "snd" or event.isEmpty == True) and messageDone == False:
messageEvents.append(event)
if Settings.DEBUG:
print event.rawString
thisMessage = Message(messageEvents)
thisMessage.setTimeLastSent(lastSnd)
#set features
thisMessage.addFeature("gender",self.gender)
thisMessage.addFeature("username",self.username)
thisMessage.addFeature("classification",self.classification)
for i in range(len(self.survey.responses)):
thisMessage.addFeature("Question "+str(i+1), self.survey.responses[i])
thisMessage.addFeature("surveyClass", sum(self.survey.responses[9:]))
messages.append(thisMessage)
#log this message in the lookup table
if event.type == "snd":
messageLookupTables['sent'].append(len(messages)-1)
else:
messageLookupTables['unsent'].append(len(messages)-1)
del messageEvents
messageEvents = []
messageDone = True
if Settings.DEBUG:
print "|||[ ",messages[-1].numEvents," events ]|||"
print "-----------------------------"
time.sleep(.1)
#now this event was the last message sent
lastSnd = event.timestampAsDatetime
#not sure why this is necessary, but it makes it work. manually set message
#done to false for each empty event to make sure non-empty event is added
elif event.isEmpty:
messageDone = True
#if the text box isn't empty, but it was empty, a new message is beginning
elif (event.isEmpty == False and messageDone == True):
messageDone = False
if Settings.DEBUG:
print self.username
print "-----------------------------"
#if the message isn't done, add the event to it
if messageDone == False:
messageEvents.append(event)
if Settings.DEBUG:
print event.rawString
return messages, messageLookupTables