Add count param to command line args
This commit is contained in:
parent
03fad1ab78
commit
a7f41da1e7
1 changed files with 5 additions and 3 deletions
|
@ -9,22 +9,24 @@ namespace MarkovGrams
|
||||||
{
|
{
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
if(args.Length != 3)
|
if(args.Length != 4)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Usage:");
|
Console.WriteLine("Usage:");
|
||||||
Console.WriteLine(" ./MarkovGrams.exe <wordlist.txt> <order> <length>");
|
Console.WriteLine(" ./MarkovGrams.exe <wordlist.txt> <order> <length> <count>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string wordlistFilename = args[0];
|
string wordlistFilename = args[0];
|
||||||
int order = int.Parse(args[1]);
|
int order = int.Parse(args[1]);
|
||||||
int desiredStringLength = int.Parse(args[2]);
|
int desiredStringLength = int.Parse(args[2]);
|
||||||
|
int count = int.Parse(args[3]);
|
||||||
|
|
||||||
IEnumerable<string> words = File.ReadLines(wordlistFilename).SelectMany(word => word.Trim().Split(' '));
|
IEnumerable<string> words = File.ReadLines(wordlistFilename).SelectMany(word => word.Trim().Split(' '));
|
||||||
IEnumerable<string> ngrams = NGrams.GenerateFlat(words, order);
|
IEnumerable<string> ngrams = NGrams.GenerateFlat(words, order);
|
||||||
|
|
||||||
UnweightedMarkovChain chain = new UnweightedMarkovChain(ngrams);
|
UnweightedMarkovChain chain = new UnweightedMarkovChain(ngrams);
|
||||||
|
|
||||||
|
for(int i = 0; i < count; i++)
|
||||||
Console.WriteLine(chain.Generate(desiredStringLength));
|
Console.WriteLine(chain.Generate(desiredStringLength));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue