예제 #1
0
def comment_by_group_user(group_id, user_id):
    author_id = get_author_id_by_user_id(user_id)
    users = get_user_by_group(group_id)
    comments = []
    for user in users:
        for post in Post.where(user_id=user):
            for comment in Comment.where(post_id=post.id):
                if comment.author_id == author_id:
                    comments.append(comment)
    return comments
예제 #2
0
def user_comment_smilar(users):
    authors = []
    for user in users:
        author = get_author_id_by_user_id(user)
        if author:
            authors.append(author)

    comments = []
    post_ids, similar = user_post_similar(users)
    for comment in comment_by_users(users):
        comments.append([comment.id, comment.content.encode('U8')])

    length = len(comments)
    comment_rela = np.zeros(length*len(post_ids), np.float)
    comment_rela = comment_rela.reshape(length, len(post_ids))
    
    for num, (i, j) in enumerate(comments):
        idf.append(i, j)
        for x, p in enumerate(post_ids):
            comment_rela[num][x] = idf.similar(i, p)
    return post_ids, similar, [i[0] for i in comments], comment_rela