Exemple #1
0
        public static void QModel(string modelName)
        {
            NGramModelBase ng1 = NGramModelFileLoader.Load <NGram1Model>();
            NGramModelBase ng2 = NGramModelFileLoader.Load <NGram2Model>();
            NGramModelBase ng3 = NGramModelFileLoader.Load <NGram3Model>();
            NGramModelBase ngn = NGramModelFileLoader.Load <NGramNModel>();

            while (true)
            {
                Console.Write("data > ");
                var    input     = Console.ReadLine();          // [char]+ [pinyin]
                string chars     = input.Split()[0];
                string pinyin    = input.Split().ElementAtOrDefault(1);
                var    condition = new Condition(chars, pinyin);
                try
                {
                    Console.WriteLine("1-gram");
                    ng1.GetDistribute(condition).Take(5).Print();
                    Console.WriteLine("2-gram");
                    ng2.GetDistribute(condition).Take(5).Print();
                    Console.WriteLine("3-gram");
                    ng3.GetDistribute(condition).Take(5).Print();
                    Console.WriteLine("n-gram");
                    ngn.GetDistribute(condition).Take(5).Print();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }
        }
 public void TestNGramN()
 {
     TestOnData(NGramModelFileLoader.Load <NGramNModel>());
 }