public bool SentenceContainsWord() { string[] sentenceArray = UserSentence.Split(" "); if (((IList <string>)sentenceArray).Contains(UserWord)) { return(true); } else { return(false); } }
public int RepeatCounter() { int counter = 0; string[] sentenceSplit = UserSentence.Split(' '); foreach (string word in sentenceSplit) { if (word.ToLower() == KeyWord) { counter += 1; } } return(counter); }
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; } } }
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); }