public static void QSolve(string modelName = "n") { NGramModelBase model = NGramModelFileLoader.LoadByName(modelName); var inputer = new NGramInputer(model); inputer.PrintDistributeSize = 5; Console.WriteLine($"Using model: {model.GetType().Name}"); while (true) { Console.Write("input > "); var input = Console.ReadLine(); try { inputer.Clear(); foreach (string pinyin in input.Split()) { inputer.Input(pinyin); } //Console.WriteLine("SubResults:"); //foreach (var result in inputer.SubResult.Take(5)) // Console.WriteLine(" " + result); Console.WriteLine(inputer.Results.First()); } catch (Exception e) { Console.WriteLine(e); } } }
public static void Solve(string inputFile, string outputFile, string modelName = "n") { var model = NGramModelFileLoader.LoadByName(modelName); var inputer = new NGramInputer(model); using (var outputWriter = File.CreateText(outputFile)) { foreach (string input in File.ReadLines(inputFile)) { inputer.Clear(); foreach (string pinyin in input.Split()) { inputer.Input(pinyin); } outputWriter.WriteLine(inputer.Results.First()); } } }