【发布时间】:2018-03-02 07:53:37
【问题描述】:
我使用 NGramTokenizer() 进行 1~3 克的分割,但似乎没有考虑标点符号,并且去掉了标点符号。
所以分词对我来说并不理想。
(如结果:氧化剂氨基,氧化剂氨基酸,颗粒氧化剂等。)
有没有什么分词方式可以保留标点符号(我想我可以在分词工作后使用词性标注过滤掉包含标点符号的字符串。)
或者有其他方法可以考虑标点符号进行分词吗?会更 非常适合我。
text <- "the slurry includes: attrition pellet, oxidant, amino acid and water."
corpus_text <- VCorpus(VectorSource(text))
content(corpus_text[[1]])
BigramTokenizer <- function(x) NGramTokenizer(x, Weka_control(min = 1, max = 3))
dtm <- DocumentTermMatrix(corpus_text, control = list(tokenize = BigramTokenizer))
mat <- as.matrix(dtm)
colnames(mat)
[1] "acid" "acid and" "acid and water"
[4] "amino" "amino acid" "amino acid and"
[7] "and" "and water" "attrition"
[10] "attrition pellet" "attrition pellet oxidant" "includes"
[13] "includes attrition" "includes attrition pellet" "oxidant"
[16] "oxidant amino" "oxidant amino acid" "pellet"
[19] "pellet oxidant" "pellet oxidant amino" "slurry"
[22] "slurry includes" "slurry includes attrition" "the"
[25] "the slurry" "the slurry includes" "water"
【问题讨论】:
-
如果只需要标点符号,也许可以基于标点符号(基于正则表达式)进行标记。这行得通吗?
标签: r tm text-segmentation