国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

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

2020-02-16 01:14:51
字體:
供稿:網(wǎng)友

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

今天介紹一個(gè)工具就是專門針對(duì)上述這種情況進(jìn)行處理的,這個(gè)工具叫做:wordninja,地址在這里。

下面簡單以實(shí)例看一下它的功能:

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é)果上來看,效果還是不錯(cuò)的,之后在實(shí)際的使用中會(huì)繼續(xù)評(píng)估。

總結(jié)

以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,謝謝大家對(duì)武林站長站的支持。如果你想了解更多相關(guān)內(nèi)容請(qǐng)查看下面相關(guān)鏈接

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 武川县| 任丘市| 浪卡子县| 托里县| 桂阳县| 广昌县| 阳原县| 宁蒗| 额济纳旗| 新邵县| 张家界市| 兴义市| 泉州市| 禄劝| 澄城县| 卢湾区| 永登县| 吉安市| 永寿县| 古交市| 惠东县| 乾安县| 河源市| 勐海县| 永清县| 特克斯县| 虎林市| 黑龙江省| 泰兴市| 泉州市| 乌拉特前旗| 三穗县| 大关县| 霞浦县| 任丘市| 抚顺市| 沐川县| 固安县| 长顺县| 偃师市| 双流县|