Brian W. Kernighan と Rob Pike による「The Practice of Programming」という本を読んでいます。第 3 章では、ソース テキストを読み取り、それを使用して「読みやすい」ランダム テキストを生成するマルコフ連鎖アプローチのアルゴリズムを提供します (意味するのは、出力が意味不明な英語よりも適切な英語に近いことを意味します)。
set w1 and w2 to the first two words in the source text
print w1 and w2
loop:
randomly choose w3, one of the successors of prefix w1 and w2 in the source text
print w3
replace w1 and w2 by w2 and w3
repeat loop
私の質問は、w2 と w3 の新しい値がソース テキストに後継者を持たない状況を処理する標準的な方法は何ですか?
よろしくお願いします!