31 lines
711 B
C#
31 lines
711 B
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.IO;
|
|||
|
|
|||
|
namespace MarkovGrams
|
|||
|
{
|
|||
|
class MainClass
|
|||
|
{
|
|||
|
public static void Main(string[] args)
|
|||
|
{
|
|||
|
if(args.Length != 3)
|
|||
|
{
|
|||
|
Console.WriteLine("Usage:");
|
|||
|
Console.WriteLine(" ./MarkovGrams.exe <wordlist.txt> <order> <length>");
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
string wordlistFilename = args[0];
|
|||
|
int order = int.Parse(args[1]);
|
|||
|
int desiredStringLength = int.Parse(args[2]);
|
|||
|
|
|||
|
IEnumerable<string> words = File.ReadLines(wordlistFilename);
|
|||
|
IEnumerable<string> ngrams = NGrams.GenerateFlat(words, order);
|
|||
|
|
|||
|
UnweightedMarkovChain chain = new UnweightedMarkovChain(ngrams);
|
|||
|
|
|||
|
Console.WriteLine(chain.Generate(desiredStringLength));
|
|||
|
}
|
|||
|
}
|
|||
|
}
|