Add additional protection against blank n-grams
This commit is contained in:
parent
7285459604
commit
8f4a3f41bd
1 changed files with 1 additions and 0 deletions
|
@ -94,6 +94,7 @@ namespace MarkovGrams
|
||||||
string[] parts = str.Split(" ".ToCharArray());
|
string[] parts = str.Split(" ".ToCharArray());
|
||||||
for (int i = 0; i < parts.Length - order; i++) {
|
for (int i = 0; i < parts.Length - order; i++) {
|
||||||
string ngram = string.Join(" ", parts.Skip(i).Take(order)).Trim();
|
string ngram = string.Join(" ", parts.Skip(i).Take(order)).Trim();
|
||||||
|
if (ngram.Trim().Length == 0) continue;
|
||||||
if (!results.ContainsKey(ngram))
|
if (!results.ContainsKey(ngram))
|
||||||
results[ngram] = 0;
|
results[ngram] = 0;
|
||||||
results[ngram]++;
|
results[ngram]++;
|
||||||
|
|
Loading…
Reference in a new issue