私のコードはここにあります
str = "Early in his first term in office, Obama signed into law economic stimulus legislation in response"
arr= str.split(" ")
set_element= arr.each_cons(2).to_a
sub_str = set_element.map {|i| i.join(' ')}
非常に大きな文字列のような大きな文字列がある場合、このタイプの結果が必要なため、このプロセスには 6.50 秒かかります
sub_str= ["Early in", "in his", "his first", "first term", "term in", "in office,", "office, Obama", "Obama signed", "signed into", "into law", "law economic", "economic stimulus", "stimulus legislation", "legislation in", "in response"]
効率的な方法で別の方法で可能ですか