A noise word is a word such as the or if that is so common that it is not useful in searches.
To Find the Noise words occurrence in a given string split the string and then compare each string in the array with the noise words list.
FindWordNoise method is to split the search string and it will call the FindNoise method to compare the words with the noise words list. If the string contains noise word then the return value at last will be 1.
private int FindWordNoise(string src) { int ret = 0; string Delimiter = "' "; string[] words = src.Split(Delimiter.ToCharArray()); for (int i = 0; i < words.Length; i++) { int srchresult = FindNoise(words[i].Trim()); if (srchresult == 1) { ret = 1; break; } } return ret; }
private int FindNoise(string src) { int ret = 0; string[] parm = { "<", ">", "-", "=", "/", "&", "(", ")", ",", "%", "the", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "$", "a", "about", "after", "all", "also", "an", "and", "another", "any", "are", "as", "at", "b", "be", "because", "been", "before", "being", "between", "both", "but", "by", "c", "came", "can", "come", "could", "d", "did", "do", "does", "e", "each", "else", "f", "for", "from", "g", "get", "got", "h", "had", "has", "have", "he", "her", "here", "him", "himself", "his", "how", "i", "if", "in", "into", "is", "it", "its", "j", "just", "k", "l", "like", "m", "make", "many", "me", "might", "more", "most", "much", "must", "my", "n", "never", "now", "o", "of", "on", "only", "or", "other", "our", "out", "over", "p", "q", "r", "re", "s", "said", "same", "see", "should", "since", "so", "some", "still", "such", "t", "take", "Test", "than", "that", "the", "their", "them", "then", "there", "these", "they", "this", "those", "through", "to", "too", "u", "under", "up", "use", "v", "very", "w", "want", "was", "way", "we", "well", "were", "what", "when", "where", "which", "while", "who", "will", "with", "would", "x", "y", "you", "your", "z" }; for (int i = 0; i < parm.Length; i++) { if (src == parm[i]) { ret = 1; return ret; } } return ret; }
|