xmlreader.py 文件源码

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

项目:StageDP 作者: EastonWang 项目源码 文件源码
def combineparse2sent(sent, parse):
    """ Combine constitent parse into sent
    """
    parse = parse.split()
    tokenlist = [token.word for token in sent.tokenlist]
    parselist, tidx = [""] * len(tokenlist), 0
    while parse:
        item = parse.pop(0)
        parselist[tidx] += (" " + item)
        partialparse = parselist[tidx].replace(' ', '')
        word = tokenlist[tidx].replace(' ', '')
        # print word, partialparse
        if (word + ')') in partialparse:
            tidx += 1
    # Attach to sent
    for (tidx, token) in enumerate(sent.tokenlist):
        item = parselist[tidx]
        sent.tokenlist[tidx].partialparse = item
    return sent
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号