data_helpers.py 文件源码

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

项目:Question-Answering-NNs 作者: nbogdan 项目源码 文件源码
def get_lemmas(sent, lemmatizer):
    stop_words = []
    res = []
    for word in sent:
        pos = get_wordnet_pos(nltk.pos_tag([word])[0][1])
        if pos == '':
            lemma = lemmatizer.lemmatize(word)
        else:
            lemma = lemmatizer.lemmatize(word, pos)
        #if(type(lemma) == unicode):
        #    lemma = lemma.encode('ascii', 'ignore')

        if lemma.isdigit():
            res.append('number')
        else:
            res.append(lemma)
    return res
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号