From a6564e4ce759f763b91f55b454328160b6b49edc Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Wed, 26 Apr 2017 21:43:45 +0100 Subject: [PATCH] Trim lines & split multiple words on a line up --- MarkovGrams/Program.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MarkovGrams/Program.cs b/MarkovGrams/Program.cs index e7741ae..d6b76cf 100644 --- a/MarkovGrams/Program.cs +++ b/MarkovGrams/Program.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Linq; namespace MarkovGrams { @@ -19,7 +20,7 @@ namespace MarkovGrams int order = int.Parse(args[1]); int desiredStringLength = int.Parse(args[2]); - IEnumerable words = File.ReadLines(wordlistFilename); + IEnumerable words = File.ReadLines(wordlistFilename).SelectMany(word => word.Trim().Split(' ')); IEnumerable ngrams = NGrams.GenerateFlat(words, order); UnweightedMarkovChain chain = new UnweightedMarkovChain(ngrams);