我有一个函数可以从字符串中提取所有有意义的单词。之后,我想用这些词创建所有可能的句子。
例如:
MyString <- "temelproblem"
使用函数拆分后,我得到一个这样的数据框;
Data <- data.frame(
myword = c("te","tem","teme","temel","em","eme","emel","me","mel","el","pr","problem","em"),
start = c(1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 6, 6, 11),
finish = c(2, 3, 4, 5, 3, 4, 5, 4, 5, 5, 7, 12, 12)
)
> Data
myword start finish
1 te 1 2
2 tem 1 3
3 teme 1 4
4 temel 1 5
5 em 2 3
6 eme 2 4
7 emel 2 5
8 me 3 4
9 mel 3 5
10 el 4 5
11 pr 6 7
12 problem 6 12
13 em 11 12
我需要所有可能的组合,规则是;下一个单词应在上一个单词结束后开始。从这个样本中我会得到;
"tem" "el" "problem"
"temel" "problem"
我将非常感谢您提供指导...