loader.py 文件源码

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

项目:Hotpot 作者: Liang-Qiu 项目源码 文件源码
def load_sts(dsfile, skip_unlabeled=True):
    """ load a dataset in the sts tsv format """
    s0 = []
    s1 = []
    labels = []
    with codecs.open(dsfile, encoding='utf8') as f:
        for line in f:
            line = line.rstrip()
            label, s0x, s1x = line.split('\t')
            if label == '':
                if skip_unlabeled:
                    continue
                else:
                    labels.append(-1.)
            else:
                labels.append(float(label))
            s0.append(word_tokenize(s0x))
            s1.append(word_tokenize(s1x))
    return (s0, s1, np.array(labels))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号