Example #1
0
        public bool Analyze(string[] tFeature)
        {
            int     i;
            NJDNode tNode;

            Debug.LogWarning("要素数:" + tFeature.Length);

            for (i = 0; i < tFeature.Length; i++)
            {
                Debug.LogWarning("要素[ " + i + " ] " + tFeature[i]);

                tNode = new NJDNode();
                tNode.Load(tFeature[i]);

                PushNode(tNode);
            }

            Debug.Log("====================================");

            SetPronunciation();
            SetDigit();
            SetAccentPhrase();
            SetAccentType();
            SetUnvoicedVowel();

            return(true);
        }
Example #2
0
        private void ConvertDigitSequence(NJDNode start, NJDNode end)
        {
            NJDNode node;
            NJDNode newnode;
            int     digit;
            int     place = 0;
            int     index;
            int     size = 0;
            int     have = 0;

            for (node = start; node != end.next; node = node.next)
            {
                size++;
            }

            if (size <= 1)
            {
                return;
            }

            if (GetDigitSequenceScore(start, end) < 0)
            {
                for (node = start, size = 0; node != end.next; node = node.next)
                {
                    if (node.Word == NJD_SET_DIGIT_ZERO1 || node.Word == NJD_SET_DIGIT_ZERO2)
                    {
                        node.Pron     = NJD_SET_DIGIT_ZERO_AFTER_DP;
                        node.MoraSize = 2;
                    }
                    else
                    if (node.Word == NJD_SET_DIGIT_TWO)
                    {
                        node.Pron     = NJD_SET_DIGIT_TWO_AFTER_DP;
                        node.MoraSize = 2;
                    }
                    else
                    if (node.Word == NJD_SET_DIGIT_FIVE)
                    {
                        node.Pron     = NJD_SET_DIGIT_FIVE_AFTER_DP;
                        node.MoraSize = 2;
                    }
                    node.ChainRule = null;
                    if (size % 2 == 0)
                    {
                        node.ChainFlag = 0;
                    }
                    else
                    {
                        node.ChainFlag = 1;
                        node.prev.Acc  = 3;
                    }
                    size++;
                }
                return;
            }

            index = size % 4;
            if (index == 0)
            {
                index = 4;
            }

            if (size > index)
            {
                place = (size - index) / 4;
            }
            index--;
            if (place > 17)
            {
                return;
            }

            for (node = start; node != end.next; node = node.next)
            {
                digit = GetDigit(node, 0);
                if (index == 0)
                {
                    if (digit == 0)
                    {
                        node.Pron     = null;
                        node.Acc      = 0;
                        node.MoraSize = 0;
                    }
                    else
                    {
                        have = 1;
                    }
                    if (have == 1)
                    {
                        if (place > 0)
                        {
                            newnode = new NJDNode();
                            newnode.Load(njd_set_digit_rule_numeral_list3[place]);
                            node = NJDNode.Insert(node, node.next, newnode);
                        }
                        have = 0;
                    }
                    place--;
                }
                else
                {
                    if (digit <= 1)
                    {
                        node.Pron     = null;
                        node.Acc      = 0;
                        node.MoraSize = 0;
                    }
                    if (digit > 0)
                    {
                        newnode = new NJDNode();
                        newnode.Load(njd_set_digit_rule_numeral_list2[index]);
                        node = NJDNode.Insert(node, node.next, newnode);
                        have = 1;
                    }
                }
                index--;
                if (index < 0)
                {
                    index = 4 - 1;
                }
            }
        }