コード例 #1
0
ファイル: Words.cs プロジェクト: kayajepson/fridayWeek7
 public bool SentenceContainsWord()
 {
     string[] sentenceArray = UserSentence.Split(" ");
     if (((IList <string>)sentenceArray).Contains(UserWord))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
コード例 #2
0
        public int RepeatCounter()
        {
            int counter = 0;

            string[] sentenceSplit = UserSentence.Split(' ');
            foreach (string word in sentenceSplit)
            {
                if (word.ToLower() == KeyWord)
                {
                    counter += 1;
                }
            }
            return(counter);
        }
コード例 #3
0
        public void TokenCount()
        {
            List <string> words = new List <string> {
            };

            string [] wordArray = UserSentence.ToLower().Split(" ");
            for (int i = 0; i < wordArray.Length; i++)
            {
                if (wordArray[i].Length > UserWord.Length)
                {
                    wordArray[i] = "";
                }
                else if (wordArray[i].Contains(UserWord))
                {
                    words.Add(wordArray[i]);
                    TokensCount = words.Count;
                }
            }
        }
コード例 #4
0
ファイル: Words.cs プロジェクト: kayajepson/fridayWeek7
        public int RepeatCounter(string userWord, string userSentence)
        {
            UserWord     = userWord.ToLower();
            UserSentence = userSentence.ToLower();
            string[] sentenceList  = UserSentence.Split(" ");
            int      timesAppeared = 0;

            foreach (string i in sentenceList)
            {
                if (i == userWord)
                {
                    timesAppeared += 1;
                }
                else
                {
                    timesAppeared += 0;
                }
            }
            return(timesAppeared);
        }