示例#1
0
        public Sentence(SentenceDefinition sd)
        {
            KanjiKana = sd.KanjiKana;
            Kana      = sd.Kana;
            var charArray = Kana.ToCharArray();
            var charList  = new List <char>(charArray);
            var strList   = charList.Select(c => c.ToString()).ToList();

            var isSokuon = false;
            var from     = 0;

            for (int i = 0; i < strList.Count(); i++)
            {
                if (i < strList.Count() - 1) //最終文字ならチャンク確定
                {
                    if (!isSokuon)
                    {
                        isSokuon = KanaUtils.IsSokuon(strList[i]);
                        if (isSokuon)
                        {
                            from--;
                            continue;
                        }
                    }

                    var chkStr = strList[i] + strList[i + 1];
                    if (KanaUtils.Henkan.ContainsKey(chkStr))
                    {
                        from--;
                        continue;
                    }
                }

                var chunkStr = "";
                for (int j = from; j < 1; j++)
                {
                    chunkStr = chunkStr + strList[i + j];
                }
                ;

                ChunkList.Add(new Chunk(chunkStr, isSokuon));
                isSokuon = false;
                from     = 0;
            }
        }