本文整理汇总了Python中models.Message.frequency方法的典型用法代码示例。如果您正苦于以下问题:Python Message.frequency方法的具体用法?Python Message.frequency怎么用?Python Message.frequency使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Message
的用法示例。
在下文中一共展示了Message.frequency方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: keyFinder
# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import frequency [as 别名]
def keyFinder(s):
engLetFreq = (0.0749, 0.0129, 0.0354, 0.0362, 0.1400, 0.0218, 0.0174, 0.0422, 0.0665, 0.0027, 0.0047, 0.0357,\
0.0339, 0.0674, 0.0737, 0.0243, 0.0026, 0.0614, 0.0695, 0.0985, 0.0300, 0.0116, 0.0169, 0.0028,\
0.0164, 0.0004)
deltamin = 1000
bestrot = 0
freq = Message.frequency(s)
for key in range(26):
d = min([delta(freq[key:]+freq[:key], engLetFreq)])
if d<deltamin:
deltamin = d
bestrot = key
return bestrot
示例2: new_message
# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import frequency [as 别名]
def new_message():
message = Message.from_json(request.json)
if message.body == "" or message.body is None:
abort(422)
elif message.mode == "" or message.mode is None:
abort(422)
db.session.add(message)
db.session.commit()
listFrequency = Message.frequency(message.body)
RoundedList = [ round(i*100, 2) for i in listFrequency ]
frequency = [{'x': alphabet[i], 'y': [RoundedList[i]]} for i in range(26)]
decipherKey = keyFinder(message.body)
answerKey = None
if decipherKey > 0 :
answerKey = decipherKey
message = Message.caesar_cipher(message)
return jsonify({"message":message.to_json(),"freequency": frequency, "answerKey": answerKey}), 201