예제 #1
0
        public override Distribution <string> GetDistribution(PinyinToSolve condition)
        {
            var dtbs = Models.Take(Math.Min(condition.N, 2) + 1)
                       .Select(m => m.GetDistribution(condition));

            return(MixDistributeStrategy(dtbs));
        }
예제 #2
0
        public static void QueryModel()
        {
            NGramBase ng1 = ModelLoader.Load <NGram1>();
            NGramBase ng2 = ModelLoader.Load <NGram2>();
            NGramBase ng3 = ModelLoader.Load <NGram3>();

            while (true)
            {
                Console.Write("Data > ");
                var    input     = Console.ReadLine().Trim(); // [char]+ [pinyin]
                string chars     = input.Split()[0];
                string pinyin    = input.Split().ElementAtOrDefault(1);
                var    condition = new PinyinToSolve(chars, pinyin);
                try
                {
                    Console.WriteLine("1-gram");
                    ng1.GetDistribution(condition).Take(5).Print();
                    Console.WriteLine("2-gram");
                    ng2.GetDistribution(condition).Take(5).Print();
                    Console.WriteLine("3-gram");
                    ng3.GetDistribution(condition).Take(5).Print();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }
        }
예제 #3
0
        public virtual Distribution <string> GetDistribution(PinyinToSolve condition)
        {
            var dtb = GetDistribution(condition.Chars);

            if (condition.Pinyin != null)
            {
                dtb = dtb.Where(str => str.Substring(1).Equals(condition.Pinyin));
            }
            return(dtb);
        }