ucca_db.py 文件源码

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

项目:nn4nlp-code 作者: neubig 项目源码 文件源码
def get_xml_trees(db, host, pid, usernames, graceful=False):
    """ Params: db, host, paragraph id, the list of usernames wanted,
        Optional:
        graceful: True if no excpetions are to be raised
        excpetion raised if a user did not submit an annotation for the passage
        returns a list of xml roots elements
        """
    cur = get_cursor(db, host)
    xmls = []
    for username in usernames:
        username = str(username)  # precaution for cases bad input e.g. 101
        cur_uid = get_uid(db, host, username)
        cur.execute("SELECT xml FROM xmls WHERE paid=" + PLACE_HOLDER +
                    " AND uid=" + PLACE_HOLDER + "ORDER BY ts DESC",
                    (pid, cur_uid))
        raw_xml = cur.fetchone()
        if not raw_xml and not graceful:
            raise Exception("The user " + username +
                            " did not submit an annotation for this passage")
        else:
            xmls.append(fromstring(raw_xml[0]))
    return xmls
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号