Exemplo n.º 1
0
        public NLPEnvironment.Entities.SentenceCollection Parse()
        {
            if (Line == null)
            {
                return(null);
            }


            var result        = new NLPEnvironment.Entities.SentenceCollection();
            var escapeControl = new NLPEnvironment.Escape.EscapeControl();


            var escapeList = escapeControl.CheckEscape(Line.Text);


            if (escapeList.Count == 0)
            {
                result.Add(new NLPEnvironment.Entities.Sentence(Line, Line.Text));
                return(result);
            }



            var startIndex = 0;

            foreach (var e in escapeList.Where(e => e.Value.EscapeType == NLPEnvironment.Escape.EscapeType.END))
            {
                var text = Line.Text.Substring(startIndex, (e.Value.Index + 1) - startIndex).Trim();

                result.Add(new NLPEnvironment.Entities.Sentence(Line, text));


                startIndex = e.Value.Index + 1;
            }



            return(result);
        }
Exemplo n.º 2
0
        public NLPEnvironment.Entities.SyllableCollection Parse()
        {
            if (Word == null)
            {
                return(null);
            }


            var result = new NLPEnvironment.Entities.SyllableCollection();


            var escapeConstol = new NLPEnvironment.Escape.EscapeControl();
            var escapeList    = escapeConstol.CheckEscape(Word.Text);


            if (escapeList.Count == 0)
            {
                escapeList.Add(0, new NLPEnvironment.Escape.EscapeItem()
                {
                    Index = Word.Text.Length, EscapeType = NLPEnvironment.Escape.EscapeType.NONE
                });
            }
            else
            {
                escapeList.Add(-1, new NLPEnvironment.Escape.EscapeItem()
                {
                    Index = Word.Text.Length, EscapeType = NLPEnvironment.Escape.EscapeType.NONE
                });
            }


            var processIndex = 0;

            foreach (var escape in escapeList)
            {
                var val   = Word.Text.Substring(processIndex, escape.Value.Index - processIndex);
                var s_val = SyllableParse(val);

                foreach (var item in s_val)
                {
                    item.SyllableType = new NLPEnvironment.Entities.SyllableNormal()
                    {
                        Text = ""
                    };
                    result.Add(item);
                }


                if (escape.Value.EscapeCharacter != null)
                {
                    result.Add(new NLPEnvironment.Entities.Syllable()
                    {
                        SyllableType = new NLPEnvironment.Entities.SyllableEscape()
                        {
                            EscapeItem = escape.Value
                        },
                        Text = Word.Text.Substring(escape.Value.Index, 1)
                    });
                }


                processIndex = escape.Value.Index + 1;
            }



            return(result);
        }