|
|
@ -77,7 +77,7 @@ namespace MarkovGrams |
|
|
|
while((Mode == GenerationMode.CharacterLevel ? result.Length : result.Split(' ').Length) < length) |
|
|
|
{ |
|
|
|
// The substring that the next ngram in the chain needs to start with
|
|
|
|
string nextStartsWith = Mode == GenerationMode.CharacterLevel ? lastNgram.Substring(1) : lastNgram.Split(' ').Last(); |
|
|
|
string nextStartsWith = Mode == GenerationMode.CharacterLevel ? lastNgram.Substring(1) : string.Join(" ", lastNgram.Split(' ').Skip(1)); |
|
|
|
// Get a list of possible n-grams we could choose from next
|
|
|
|
List<string> nextNgrams = ngrams.FindAll(gram => gram.StartsWith(nextStartsWith)); |
|
|
|
choiceCounts.Add(nextNgrams.Count); |
|
|
@ -90,7 +90,7 @@ namespace MarkovGrams |
|
|
|
if (Mode == GenerationMode.CharacterLevel) |
|
|
|
result += nextNgram[nextNgram.Length - 1]; |
|
|
|
else |
|
|
|
result += ' ' + string.Join(" ", nextNgram.Split(' ').Skip(1)); |
|
|
|
result += ' ' + nextNgram.Split(' ').Last(); |
|
|
|
|
|
|
|
lastNgram = nextNgram; i++; |
|
|
|
} |
|
|
|