Esempio n. 1
0
        public int FindWord(string inputWord, string inputText)
        {
            CountWords newCountWords = new CountWords();

            char[]   separator  = { ' ' };
            String[] inputArray = inputText.Split(separator, StringSplitOptions.RemoveEmptyEntries);
            var      matchQuery = from word in inputArray
                                  where word == inputWord
                                  select word;
            int wordCount = matchQuery.Count();

            return(wordCount);
        }
Esempio n. 2
0
        public int CountSecondWord()
        {
            string[]   sentSplit   = _sent.Split(' ');
            CountWords newCounters = new CountWords();
            int        counterTwo  = newCounters.GetCounterTwo();

            for (int i = 0; i < sentSplit.Length; i++)
            {
                while (sentSplit[i].EndsWith(',') || sentSplit[i].EndsWith('?') || sentSplit[i].EndsWith('!') || sentSplit[i].EndsWith('.') || sentSplit[i].EndsWith(':') || sentSplit[i].EndsWith(';'))
                {
                    sentSplit[i] = sentSplit[i].Remove(sentSplit[i].Length - 1);
                }
                if (_wordTwo == sentSplit[i])
                {
                    counterTwo += 1;
                }
            }
            return(counterTwo);
        }