本文整理汇总了Python中model.Comment.select方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.select方法的具体用法?Python Comment.select怎么用?Python Comment.select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.Comment
的用法示例。
在下文中一共展示了Comment.select方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_data
# 需要导入模块: from model import Comment [as 别名]
# 或者: from model.Comment import select [as 别名]
def get_data():
query = Comment.select()
num_data = []
corpuses = []
for comment in query:
data, corpus = create_row(comment)
num_data.append(data)
corpuses.append(corpus)
return (np.array(num_data), np.array(corpuses))
示例2: submit_guesses
# 需要导入模块: from model import Comment [as 别名]
# 或者: from model.Comment import select [as 别名]
def submit_guesses():
data = json.loads(request.forms.get("data"))
answers = data['answers']
quiz_type = data['type']
num_correct = 0
total = len(answers)
for guess in answers:
UserGuess.create(guess=int(guess['answer']), comment=guess['comment_id'], quiz_type=quiz_type)
actual_count = Comment.select().where(Comment.c_id == guess['comment_id'])[0].upvotes
num_correct += 1 if detect_group(actual_count) == int(guess['answer']) else 0
return json.dumps({"num_correct": num_correct, "total": total})
示例3: list
# 需要导入模块: from model import Comment [as 别名]
# 或者: from model.Comment import select [as 别名]
def list(self):
results = Comment.select(Comment.q.handled == False).reversed()
return dict(title="BandRadar Comments", grid=datagrid, data=results)
示例4: training_comments
# 需要导入模块: from model import Comment [as 别名]
# 或者: from model.Comment import select [as 别名]
def training_comments(test_ids, limit=None):
test_set = set(test_ids)
comments = Comment.select().join(Submission, on=(Comment.submission == Submission.s_id))
return filter(lambda comment: comment.c_id not in test_set, comments)
示例5: from_group
# 需要导入模块: from model import Comment [as 别名]
# 或者: from model.Comment import select [as 别名]
def from_group(group, groups=groups, num=3):
"""from_group(group[, groups=default_defs, num=3])
Returns list of num random rows from the comment table based on the a definition held in groups with identifier group"""
return list(Comment.select().where(groups[group](Comment.upvotes)).order_by(fn.Rand()).limit(num))