美文网首页
python自然语言处理segment分词

python自然语言处理segment分词

作者: _Haimei | 来源:发表于2018-07-02 14:38 被阅读10次
text = "doyouseethekittyseethedoggydoyoulikethekittylikethedoggy"

seg1= "0000000000000001000000000010000000000000000100000000000"

seg2= "0100100100100001001001000010100100010010000100010010000"

def segment(text,segs):

    words=[]

    last=0

    for i in range(len(segs)):

        if segs[i]=='1':

            words.append(text[last:i+1])

            last=i+1

    words.append(text[last:])

    return words

segment(text, seg1)
segment(text, seg2)

原文请看:https://www.cnblogs.com/createMoMo/archive/2013/05/24/3097523.html

相关文章

网友评论

      本文标题:python自然语言处理segment分词

      本文链接:https://www.haomeiwen.com/subject/tncluftx.html