示例#1
0
        private IDajare connectWithDoshi(IWord doshi)
        {
            if (doshi.GetHinshi() != Hinshi.Doshi)
            {
                throw new Exception();
            }
            IDajare       res = new Dajare();
            WordEvaluator we  = WordEvaluator.GetInstance();

            IWord[] 助詞s =
            {
                new Word("を", Hinshi.Joshi),
                new Word("へ", Hinshi.Joshi),
                new Word("が", Hinshi.Joshi)
            };
            IWord best助詞 = null;
            long  max    = 0;

            foreach (IWord j in 助詞s)
            {
                long e1   = we.Evaluate(meishi.ToKanji() + j.ToKanji());
                long e2   = we.Evaluate(j.ToKanji() + doshi.ToKanji());
                long eval = e1 * e1 + e2 * e2;
                if (max > eval)
                {
                    max    = eval;
                    best助詞 = j;
                }
            }
            res.Add(this.meishi);
            res.Add(best助詞);
            res.Add(doshi);
            return(res);
        }
示例#2
0
        private IDajare connectWithRentaishi(IWord rentaishi)
        {
            if (rentaishi.GetHinshi() != Hinshi.Rentaishi)
            {
                throw new Exception();
            }
            IDajare res = new Dajare();

            res.Add(rentaishi);
            res.Add(this.meishi);
            return(res);
        }
示例#3
0
        private IDajare connectWithKeiyoshi(IWord keiyoshi)
        {
            if (keiyoshi.GetHinshi() != Hinshi.Keiyoshi)
            {
                throw new Exception();
            }
            IDajare res = new Dajare();

            res.Add(this.meishi);
            res.Add(new Word("は", Hinshi.Joshi));
            res.Add(keiyoshi);
            return(res);
        }
示例#4
0
        private IDajare connectWithMeishi(IWord meishi)
        {
            if (meishi.GetHinshi() != Hinshi.Meishi)
            {
                throw new Exception();
            }
            IDajare       res = new Dajare();
            WordEvaluator we  = WordEvaluator.GetInstance();

            IWord[] testers  = { new Word("な", Hinshi.Joshi), new Word("は", Hinshi.Joshi) };
            long    max      = -114514;
            IWord   better助詞 = null;

            foreach (IWord j in testers)
            {
                long eval = we.Evaluate(this.meishi.ToKanji() + j.ToKanji());
                if (max < eval)
                {
                    max      = eval;
                    better助詞 = j;
                }
            }
            if (better助詞.ToHiragana() == "な")
            {
                res.Add(this.meishi);
                res.Add(better助詞);
                res.Add(meishi);
                return(res);
            }
            IWord[] 助詞s =
            {
                new Word("は",  Hinshi.Joshi),
                new Word("と",  Hinshi.Joshi),
                new Word("より", Hinshi.Joshi),
                new Word("の",  Hinshi.Joshi)
            };
            Random random = new Random();

            res.Add(this.meishi);
            res.Add(助詞s[random.Next(助詞s.Length)]);
            res.Add(meishi);
            return(res);
        }