本文整理汇总了Python中Message.Message.create方法的典型用法代码示例。如果您正苦于以下问题:Python Message.create方法的具体用法?Python Message.create怎么用?Python Message.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Message.Message
的用法示例。
在下文中一共展示了Message.create方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: len
# 需要导入模块: from Message import Message [as 别名]
# 或者: from Message.Message import create [as 别名]
from Message import Message
from MessageSentimentMeans import MessageSentimentMeans
from MessageSentimentCorrelations import MessageSentimentCorrelations
qStatistics = "Data/FullQuestionStatistics.txt"
aStatistics = "Data/FullAnswerStatistics.txt"
qSentiments = "Data/QuestionSentiments.txt"
aSentiments = "Data/AnswerSentiments.txt"
outMeans = "Out/SentimentMeans.txt"
outCorrelations = "Out/SentimentCorrelations.txt"
messages = []
# with codecs.open(qStatistics, "r", "utf-8-sig") as f:
# messages = [Message.create(line) for line in f.readlines()]
with codecs.open(aStatistics, "r", "utf-8-sig") as f:
messages.extend([Message.create(line) for line in f.readlines()])
id_to_messages = {message.own_id: message for message in messages}
for name in qSentiments, aSentiments:
with codecs.open(name, "r", "utf-8-sig") as f:
splitted_lines = [line.strip().split("\t") for line in f.readlines()]
for parts in splitted_lines:
if len(parts) < 2:
continue
own_id = int(parts[0])
sentiment = float(parts[1])
if own_id in id_to_messages:
id_to_messages[own_id].sentiment = sentiment
means = MessageSentimentMeans(id_to_messages.values())
with codecs.open(outMeans, "w", "utf-8-sig") as f:
示例2: raw_input
# 需要导入模块: from Message import Message [as 别名]
# 或者: from Message.Message import create [as 别名]
from Message import Message
name = raw_input('Enter name: ')
while True:
command = raw_input('Enter command: ')
if command == 'chat':
for msg in Message.select():
print msg
elif command == 'message' or command == 'msg':
Message.create(name=name,
text_message=raw_input('Enter message: '))
elif command == 'rename':
name = raw_input('Enter name: ')
elif command == 'help':
print 'Commands: "chat" - View chat! ' \
'"msg or message" - Send message! ' \
'"rename" - change name ' \
'"Exit or exit" - exit application'
elif command == 'Exit' or command == 'exit':
print 'goodbye'
break
else:
print 'command not found!'