public bool LoadOptionalWords(string line) { try { // 3 is not a magic number, it's just to make sure that the white space(s) are considered as optional keywords mistakenly if (line.Length > 3) { HasOptionalWords = true; string[] tempKeywords = line.Split(new char[] { ',' }, line.Length, StringSplitOptions.RemoveEmptyEntries); TotalKeywords += tempKeywords.Length; for (int ind = 0; ind < tempKeywords.Length; ind++) { OtherOptionalWords.Add( _stemmer.Stem( tempKeywords[ind] .Replace("@", "") .Replace("#", "") .ToLower() ).Value ); IsOtherOptionalWordsHit.Add(false); } } return(true); } catch (Exception ex) { return(false); } }
public void Match(string candidateWord, ref int topicHitCount, ref int keywordHitCout) { candidateWord = candidateWord.Replace("@", "").Replace("#", ""); int tempKeyIndex; foreach (Topic t in ActualTopicList) { // apply the condition for handling "win" and "won", they are still there as a separate words in the results. if ((tempKeyIndex = t.TopicKeywords.IndexOf(candidateWord)) >= 0) { if (!t.TopicKeywordHit[tempKeyIndex]) { t.TopicKeywordHit[tempKeyIndex] = true; keywordHitCout++; } if (!t.Hit) { t.Hit = true; topicHitCount++; } } } if (HasOptionalWords) { if ((tempKeyIndex = OtherOptionalWords.IndexOf(candidateWord)) >= 0) { if (!IsOtherOptionalWordsHit[tempKeyIndex]) { keywordHitCout++; IsOtherOptionalWordsHit[tempKeyIndex] = true; } } } }