Skip to content

Commit

Permalink
類似コメントがないものだけに絞る
Browse files Browse the repository at this point in the history
  • Loading branch information
3w36zj6 committed Oct 29, 2021
1 parent afd98d2 commit 6504c7d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions web/app.py
Expand Up @@ -79,7 +79,9 @@ def post_comment():
else:
# 類似コメント
candidates = []
for old_comment in Comment.query.filter_by(parent_comment_id=new_comment.parent_comment_id).all():
for old_comment in Comment.query.filter_by(
parent_comment_id=new_comment.parent_comment_id
).all():
similarity = get_similarity(new_comment.body, old_comment.body)
if similarity >= 0.6: # 閾値
candidates.append(
Expand Down Expand Up @@ -126,13 +128,13 @@ def get_comment(comment_id):
@app.route("/comment/<comment_id>/replies", methods=["GET"])
def get_reply_comments(comment_id):
agree_replies = Comment.query.filter_by(
parent_comment_id=comment_id, position=1
parent_comment_id=comment_id, position=1, similar_to="0"
).all()
disagree_replies = Comment.query.filter_by(
parent_comment_id=comment_id, position=-1
parent_comment_id=comment_id, position=-1, similar_to="0"
).all()
neutral_replies = Comment.query.filter_by(
parent_comment_id=comment_id, position=0
parent_comment_id=comment_id, position=0, similar_to="0"
).all()
return jsonify(
{
Expand Down

0 comments on commit 6504c7d

Please sign in to comment.