示例#1
0
        public override IEnumerable<TokenResult> Parse(string input, string UserId)
        {
            var tokenResults = new List<TokenResult>();
            string remainder = string.Empty;

            var results = base.Parse(input, UserId);

            if (results.Any())
            {
                tokenResults.Add(results.OrderByDescending(qty => qty.Length).First());

                int startPos = tokenResults.First().Start + tokenResults.First().Length + 1;

                if (startPos < input.Length)
                {
                    remainder = input.Substring(startPos);

                    if (remainder.Length > 0)
                    {
                        results = new TokenLook().Parse(remainder, UserId);
                        if (results.Any())
                        {
                            var tokenLook = results.OrderByDescending(token => token.Start).First();

                            tokenLook.Start += startPos;
                            startPos = tokenLook.Start + tokenLook.Length + 1;

                            tokenResults.Add(tokenLook);

                            remainder = (remainder.Length <= tokenLook.Length) ? string.Empty : remainder.Substring(tokenLook.Length + 1);
                        }

                        if (!string.IsNullOrEmpty(remainder))
                        {
                            tokenResults.Add(new TokenResult
                            {
                                Length = remainder.Length,
                                Start = startPos,
                                Token = new TokenQuotedPhrase { Value = remainder },
                                TokenType = typeof(TokenQuotedPhrase).ToString(),
                                Value = remainder
                            });
                        }
                    }
                }
            }

            return tokenResults;
        }
示例#2
0
 /* Eg: what's my cash flow look like today */
 public static void CashFlowResponse(ConversationContext cContext, TokenRequest p1, TokenCashFlow p2, TokenLook p3, TokenQuotedPhrase p4)
 {
     cContext.Say(CreateResponse(p2.Value.ToString()), null);
 }