Browse Source

Add additional protection against blank n-grams

master
Starbeamrainbowlabs 2 years ago
parent
commit
8f4a3f41bd
Signed by: sbrl GPG Key ID: 1BE5172E637709C2
1 changed files with 1 additions and 0 deletions
  1. +1
    -0
      MarkovGrams/NGrams.cs

+ 1
- 0
MarkovGrams/NGrams.cs View File

@ -94,6 +94,7 @@ namespace MarkovGrams
string[] parts = str.Split(" ".ToCharArray());
for (int i = 0; i < parts.Length - order; i++) {
string ngram = string.Join(" ", parts.Skip(i).Take(order)).Trim();
if (ngram.Trim().Length == 0) continue;
if (!results.ContainsKey(ngram))
results[ngram] = 0;
results[ngram]++;


Loading…
Cancel
Save