Exemplo n.º 1
0
        //--------------------------------------
        // OBJECT      = [ADJECTIVE LIST] <NOUN>
        // OBJECT      = <PRONOUN>
        internal bool ParseObject(TokenSet tokens, TokenCommand cmd)
        {
            var finished    = false;
            var tokenObject = new TokenObject();

            if (tokens.Current.MorphType == MorphType.Adjective)
            {
                ParseAdjectiveList(tokens, tokenObject);
                finished = tokens.IsFinished;
            }

            if (!finished)
            {
                switch (tokens.Current.MorphType)
                {
                case MorphType.Noun:
                    tokenObject.Noun = tokens.Current.Value;
                    tokens.MoveNext();
                    cmd.Objects.Add(tokenObject);
                    finished = true;
                    break;

                case MorphType.Pronoun:
                    finished = ParseObjectPronoun(tokens.Current, tokenObject, cmd);
                    tokens.MoveNext();
                    break;
                }
            }

            return(finished);
        }
Exemplo n.º 2
0
        internal bool ParseSubject(TokenSet tokens, TokenCommand cmd)
        {
            var tokenObject = new TokenObject();

            var result = false;

            if (tokens.Current.MorphType == MorphType.Adjective)
            {
                ParseAdjectiveList(tokens, tokenObject);
                if (tokens.Current == null)
                {
                    return(result);
                }
            }

            switch (tokens.Current.MorphType)
            {
            case MorphType.Noun:
                tokenObject.Noun = tokens.Current.Value;
                tokens.MoveNext();
                cmd.Subjects.Add(tokenObject);
                result = true;
                break;

            case MorphType.Pronoun:
                result = ParseSubjectPronoun(tokens.Current, tokenObject, cmd);
                tokens.MoveNext();
                break;
            }

            return(result);
        }
Exemplo n.º 3
0
        internal void ParseAdjectiveList(TokenSet tokens, TokenObject tokenObject)
        {
            if (tokens.Current.MorphType != MorphType.Adjective)
            {
                return;
            }

            var finished = false;

            while (!finished)
            {
                switch (tokens.Current.MorphType)
                {
                case MorphType.Adjective:
                    tokenObject.Adjectives.Add(tokens.Current);
                    finished = !tokens.MoveNext();
                    break;

                case MorphType.Conjunction:
                    finished = !tokens.MoveNext();
                    break;

                default:
                    finished = true;
                    break;
                }
            }
        }
Exemplo n.º 4
0
        internal bool ParseSubjectPronoun(Token pronoun, TokenObject tokenObject, TokenCommand cmd)
        {
            var result = false;

            if (pronoun.Value == _thesaurus.Keywords.PronounAll || pronoun.Value == _thesaurus.Keywords.PronounEverything)
            {
                tokenObject.Noun = _thesaurus.Keywords.NounAll;
                cmd.Subjects.Add(tokenObject);
                result = true;
            }
            else if (pronoun.Value == _thesaurus.Keywords.PronounMe)
            {
                tokenObject.Noun = _thesaurus.Keywords.NounMyName;
                cmd.Subjects.Add(tokenObject);
                result = true;
            }

            return(result);
        }