当前位置: 首页>>代码示例>>Python>>正文


Python Message.create方法代码示例

本文整理汇总了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:
开发者ID:bellal89,项目名称:MedicalSentiment,代码行数:33,代码来源:main.py

示例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!'
开发者ID:AntonReytarovskiy,项目名称:Python-chat,代码行数:30,代码来源:Main.py


注:本文中的Message.Message.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。