public void TestOnData(NGramModelBase model) { PinyinDict pydict = model.PinyinDict; var inputer = new NGramInputer(model); var tester = new InputerTester(inputer); using (var inputFile = File.OpenText(testInputPath)) //using (var outputFile = File.CreateText(testOutputPath)) tester.TestData(inputFile, Console.Out); // Assert("Check the output."); }
public static void TestOnData(TestOption opt) { IEnumerable <NGramModelBase> models; if (opt.StatFiles == null) { models = opt.ModelNames.Select(NGramModelFileLoader.LoadByName); } else { models = from stat in opt.StatFiles.Select(path => new TextStatistician(path)) from model in opt.ModelNames.Select(name => { var model = NGramModelFileLoader.NewByName(name); Console.WriteLine($"Built model: [{name}] from [{stat.SourceName}]"); model.FromStatistician(stat); return(model); }) select model; } var inputers = models.Select(model => new NGramInputer(model)).Cast <FullPinyinInputer>().ToArray(); var tester = new InputerTester(inputers); using (var inputFile = File.OpenText(opt.InputFile)) { if (opt.OutputFile == null) { tester.TestData(inputFile, Console.Out, opt.Format); } else { using (var outputFile = File.CreateText(opt.OutputFile)) tester.TestData(inputFile, outputFile, opt.Format); } } }