Exemplo n.º 1
0
        public Sentence_Parser load(string key, Sentence_Parser sentence)
        {
            last_word = sentence.last_word;

            if (source.key.Length > 0)
            {
                key = source.key;
            }

            if (original_phrase.get_element(id) != null)
            {
                if (sentence.last_word != null)
                {
                    last_word = sentence.last_word;
                }

                foreach (var original in sentence.original_words)
                {
                    if (original.text == id)
                    {
                        confidence = original.confidence;
                        sentence.original_words.Remove(original);
                        break;
                    }
                }

                sentence.last_word = this;
            }
            else if (text != "" || source.GetType() == typeof(Element_Word))
            {
                sentence.last_word = this;
            }

            foreach (Token child in children)
            {
                sentence = child.load(key, sentence);
            }

            if (source.GetType() == typeof(Element_Item))
            {
                foreach (Action action in ((Element_Item)source).actions)
                {
                    actions.Add(action);
                }

                if (actions.Count > 0)
                {
                    original_phrase.final_action = actions[actions.Count - 1];
                }
            }

            return(sentence);
        }
Exemplo n.º 2
0
        public void process()
        {
            words = new List <Token>();
            text  = get_text(0, -1);

            LinkedList <Token> original_words = new LinkedList <Token>();

            foreach (ISpeechPhraseElement element in phrase.Elements)
            {
                original_words.AddLast(initialize_word(element));
            }

            if (phrase.Properties != null)
            {
                foreach (ISpeechPhraseProperty property in phrase.Properties)
                {
                    //     if (property.EngineConfidence >= 0.4)
                    {
                        Token transition = initialize_word(property);
                        if (transition != null)
                        {
                            words.Add(transition);
                        }
                        else
                        {
                            //SilentOrb.Utility.Feedback.print("error", SilentOrb.Utility.Feedback.Status.debug);
                        }
                    }
                    //break;
                }

                if (words.Count != 0)
                {
                    if (words[words.Count - 1].source == null)
                    {
                        return;
                    }

                    document = words[words.Count - 1].source.document;
                    Sentence_Parser sentence = new Sentence_Parser();
                    sentence.last_word      = null;
                    sentence.original_words = original_words;

                    foreach (Token transition in words)
                    {
                        sentence = transition.load("", sentence);
                    }
                }
            }
        }