documents_api.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:LDA-REST 作者: valentinarho 项目源码 文件源码
def get(self, model_id, topic_id=None):
        """
        Get all documents that have a topic assignment in model model_id

        :param model_id:
        :return:
        """
        topic_weight = 0.0

        if topic_id is not None:
            topic_id = int(topic_id)

            parser = reqparse.RequestParser(bundle_errors=True)
            parser.add_argument('threshold', default=0.0, required=False,
                                type=float, help='The minimum probability that the specified topic should '
                                     'have to consider that document as related.')

            args = parser.parse_args()
            topic_weight = args['threshold']

        data = {'documents': db_utils.get_all_documents(model_id, topic_id, topic_weight)}

        # data = api_utils.filter_only_exposed(data, config.exposed_fields['documents'])
        response = 'Documents retrieved.'

        return api_utils.prepare_success_response(200, response, marshal(data, api_utils.documents_fields)['documents'])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号