欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Python英文文本分詞(無空格)模塊wordninja的使用實例

 更新時間:2019年02月20日 08:29:27   作者:Together_CZ  
今天小編就為大家分享一篇關(guān)于Python英文文本分詞(無空格)模塊wordninja的使用實例,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧

在NLP中,數(shù)據(jù)清洗與分詞往往是很多工作開始的第一步,大多數(shù)工作中只有中文語料數(shù)據(jù)需要進行分詞,現(xiàn)有的分詞工具也已經(jīng)有了很多了,這里就不再多介紹了。英文語料由于其本身存在空格符所以無需跟中文語料同樣處理,如果英文數(shù)據(jù)中沒有了空格,那么應該怎么處理呢?

今天介紹一個工具就是專門針對上述這種情況進行處理的,這個工具叫做:wordninja,地址在這里

下面簡單以實例看一下它的功能:

def wordinjaFunc():
  '''
  https://github.com/yishuihanhan/wordninja
  '''
  import wordninja
  print wordninja.split('derekanderson')
  print wordninja.split('imateapot')
  print wordninja.split('wethepeopleoftheunitedstatesinordertoformamoreperfectunionestablishjusticeinsuredomestictranquilityprovideforthecommondefencepromotethegeneralwelfareandsecuretheblessingsoflibertytoourselvesandourposteritydoordainandestablishthisconstitutionfortheunitedstatesofamerica')
  print wordninja.split('littlelittlestar')

結(jié)果如下:

['derek', 'anderson']
['im', 'a', 'teapot']
['we', 'the', 'people', 'of', 'the', 'united', 'states', 'in', 'order', 'to', 'form', 'a', 'more', 'perfect', 'union', 'establish', 'justice', 'in', 'sure', 'domestic', 'tranquility', 'provide', 'for', 'the', 'common', 'defence', 'promote', 'the', 'general', 'welfare', 'and', 'secure', 'the', 'blessings', 'of', 'liberty', 'to', 'ourselves', 'and', 'our', 'posterity', 'do', 'ordain', 'and', 'establish', 'this', 'constitution', 'for', 'the', 'united', 'states', 'of', 'america']
['little', 'little', 'star']

從簡單的結(jié)果上來看,效果還是不錯的,之后在實際的使用中會繼續(xù)評估。

總結(jié)

以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家的學習或者工作具有一定的參考學習價值,謝謝大家對腳本之家的支持。如果你想了解更多相關(guān)內(nèi)容請查看下面相關(guān)鏈接

相關(guān)文章

最新評論