使用Rwordseg進行分詞

2021-06-22 01:55:21 字數 806 閱讀 8051

1、文字簡介:

$wc text.txt

0 121467 4694908

2、使用rwordseg進行文字挖掘。

(1)使用r**:

library(rwordseg)

require(rwordseg)

text <- readlines("text.txt") #輸入

seg <- unlist(segmentcn(text)) #使用segmentcn進行分詞

tag <- table(seg)

tbldf <- as.data.frame(tag)

freqord <- order(tbldf$freq, decreasing=true) #資料彙總 #見參考文獻

final <- tbldf[freqord,][1:length(tag),] #最終結果

write.table(final, "final.csv", sep=",") #輸出

system.time(seg <- unlist(segmentcn(text)))

user system elapsed

21.074 0.149 20.594

可見,對約135萬字的文字進行挖掘需要約20秒。(os x 10.9, i7, 16g)

3、參考文獻

**中的資料彙總方法使用了norman matloff "the art of r programming" p134-136的方法。

使用pyhanlp進行分詞

from pyhanlp import def my segment sentence seg hanlp.segment sentence seg2 list seg seg3 list map lambda x str x seg2 seg4 list map lambda x x.split ...

使用pymmseg進行中文分詞

python分詞模組,基於mmseg演算法編寫,核心 c 提供python介面。code example coding utf 8 from pymmseg import mmseg import os import sys def cws pymmseg shortdeslist,wordlist...

使用python jieba庫進行中文分詞

jieba 結巴 中文分詞 做最好的 python 中文分詞元件 jieba chinese for to stutter chinese text segmentation built to be the best python chinese word segmentation module.功...