public bool Match(string input)
        {
            //Remove question mark
            input = input.Substring(0, input.Length - 1);

            bool isQuestion = (input.StartsWith("how many", StringComparison.OrdinalIgnoreCase));

            if (!isQuestion)
            {
                return(false);
            }

            string[] parts = input.Split(new string[] { " is " }, StringSplitOptions.RemoveEmptyEntries);
            if (parts.Length != 2)
            {
                return(false);
            }

            string[] preIsWords = parts[0].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            if (preIsWords.Length < 3)
            {
                return(false);
            }

            string[] postIsWords = parts[1].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            if (postIsWords.Length < 2)
            {
                return(false);
            }

            return(helper.AreWordsValidCommodities(preIsWords.Skip(preIsWords.Length - 1).ToArray()) &&
                   helper.AreWordsValidCommodities(postIsWords.Skip(postIsWords.Length - 1).ToArray()) &&
                   helper.AreWordsValidAliases(postIsWords.Take(postIsWords.Length - 1).ToArray()));
        }
Exemple #2
0
        public bool Match(string input)
        {
            //Remove question mark from the last alias
            input = input.Substring(0, input.Length - 1);

            bool isQuestion = (input.StartsWith("how much", StringComparison.OrdinalIgnoreCase));

            if (!isQuestion)
            {
                return(false);
            }

            string[] parts = input.Split(new string[] { " is " }, StringSplitOptions.RemoveEmptyEntries);
            if (parts.Length != 2)
            {
                return(false);
            }

            string[] words = parts[1].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            if (words.Length < 1)
            {
                return(false);
            }

            return(helper.AreWordsValidAliases(words));
        }
Exemple #3
0
        public bool Match(string input)
        {
            //Remove question mark
            input = input.Substring(0, input.Length - 1);

            bool isQuestion = (input.StartsWith(Constant.MetalExpression, StringComparison.OrdinalIgnoreCase));

            if (!isQuestion)
            {
                return(false);
            }

            string[] parts = Regex.Split(input, Constant.ExpressionSplitter, RegexOptions.IgnoreCase);
            if (parts.Length != 2)
            {
                return(false);
            }

            string[] words = parts[1].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            if (words.Length < 1)
            {
                return(false);
            }

            return(_helper.AreWordsValidAliases(words.Take(words.Length - 1).ToArray()) &&
                   _helper.AreWordsValidMetals(words.Skip(words.Length - 1).ToArray()));
        }
Exemple #4
0
        public bool Match(string input)
        {
            //Remove question mark
            input = input.ToUpper().Substring(0, input.Length - 1);

            bool isQuestion = (input.StartsWith("HOW MANY", StringComparison.OrdinalIgnoreCase));

            if (!isQuestion)
            {
                return(false);
            }

            string[] parts = input.Split(new string[] { " IS " }, StringSplitOptions.RemoveEmptyEntries);
            if (parts.Length != 2)
            {
                return(false);
            }

            string[] words = parts[1].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            if (words.Length < 1)
            {
                return(false);
            }

            return(_helper.AreWordsValidAliases(words.Take(words.Length - 1).ToArray()) &&
                   _helper.AreWordsValidCommodities(words.Skip(words.Length - 1).ToArray()));
        }
        public bool Match(string input)
        {
            string[] parts = input.Split(new string[] { " is " }, StringSplitOptions.RemoveEmptyEntries);
            if (parts.Length != 2)
            {
                return(false);
            }

            string[] wordsInFirstPart  = parts[0].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            string[] wordsInSecondPart = parts[1].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            double   output;

            return(input.EndsWith("credits", StringComparison.OrdinalIgnoreCase) &&
                   !input.StartsWith("how many", StringComparison.OrdinalIgnoreCase) && parts.Length == 2 &&
                   wordsInSecondPart.Length == 2 && Double.TryParse(wordsInSecondPart[0], out output) &&
                   _helper.AreWordsValidAliases(wordsInFirstPart.Take(wordsInFirstPart.Length - 1).ToArray()));
        }