这是我关于SO的第一个问题,请告诉我是否可以改进.我正在研究R中的自然语言处理项目,并且正在尝试构建包含测试用例的data.table.在这里,我构建了一个简化的示例:
texts.dt <- data.table(string = c("one",
"two words",
"three words here",
"four useless words here",
"five useless meaningless words here",
"six useless meaningless words here just",
"seven useless meaningless words here just to",
"eigth useless meaningless words here just to fill",
"nine useless meaningless words here just to fill up",
"ten useless meaningless words here just to fill up space"),
word.count = 1:10,
stop.at.word = c(0, 1, 2, 2, 4, 3, 3, 6, 7, 5))
Run Code Online (Sandbox Code Playgroud)
这将返回我们将要处理的data.table:
string word.count stop.at.word
1: …
Run Code Online (Sandbox Code Playgroud)