如何在 R 中标记字符串?

How can I tokenize a string in R?

我正在尝试计算可读性,但似乎所有内容都是为了期望文件路径或语料库而编写的。我如何处理字符串?

错误(在标记化步骤):

Error: Unable to locate

我试过了:

str<-"Readability zero one.  Ten, Eleven.", "The cat in a dilapidated tophat."
library(koRpus)
ll.tagged <- tokenize(str, lang="en")
readability(ll.tagged,measure="Flesch.Kincaid")

您需要下载语言文件

install.koRpus.lang(c("en"))
library(koRpus.lang.en)
ll.tagged <- tokenize(str,  format = "obj", lang = "en")
ll.tagged
   doc_id       token      tag lemma lttr   wclass desc stop stem idx sntc
1    <NA> Readability word.kRp         11     word <NA> <NA> <NA>   1    1
2    <NA>        zero word.kRp          4     word <NA> <NA> <NA>   2    1
3    <NA>         one word.kRp          3     word <NA> <NA> <NA>   3    1
4    <NA>           .     .kRp          1 fullstop <NA> <NA> <NA>   4    1
5    <NA>         Ten word.kRp          3     word <NA> <NA> <NA>   5    2
6    <NA>           ,     ,kRp          1    comma <NA> <NA> <NA>   6    2
                                             [...]                        
10   <NA>         cat word.kRp          3     word <NA> <NA> <NA>  10    3
11   <NA>          in word.kRp          2     word <NA> <NA> <NA>  11    3
12   <NA>           a word.kRp          1     word <NA> <NA> <NA>  12    3
13   <NA> dilapidated word.kRp         11     word <NA> <NA> <NA>  13    3
14   <NA>      tophat word.kRp          6     word <NA> <NA> <NA>  14    3
15   <NA>           .     .kRp          1 fullstop <NA> <NA> <NA>  15    3