private static string ParseNormalSearchTerms(string query, SandoQueryDescription sandoQueryDescription)
        {
            query = Regex.Replace(query, InvalidCharactersRegex, " ");
            //ensure non-split query terms are added too.
            var nonSplitTerms = query.Split(' ');

            foreach (var nonSplit in nonSplitTerms)
            {
                if (!String.Empty.Equals(nonSplit))
                {
                    sandoQueryDescription.SearchTerms.Add(nonSplit.Trim());
                }
            }
            var wordSplitter = new WordSplitter();
            var searchTerms  = wordSplitter.ExtractWords(query).Where(w => !String.IsNullOrWhiteSpace(w));

            foreach (var searchTerm in searchTerms)
            {
                sandoQueryDescription.SearchTerms.Add(searchTerm.Trim());
                query = query.Replace(searchTerm, " ");
            }

            sandoQueryDescription.SearchTerms = sandoQueryDescription.SearchTerms.Distinct().ToList();
            return(query);
        }
        private static string ParseNormalSearchTerms(string query, SandoQueryDescription sandoQueryDescription)
        {
            query = Regex.Replace(query, InvalidCharactersRegex, " ");
            var wordSplitter = new WordSplitter();

            //add unsplit words
            var splitTerms = query.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            foreach (string term in splitTerms)
            {
                sandoQueryDescription.SearchTerms.Add(term.Trim());
            }

            var searchTerms = wordSplitter.ExtractWords(query).Where(w => !String.IsNullOrWhiteSpace(w));

            foreach (var searchTerm in searchTerms)
            {
                sandoQueryDescription.SearchTerms.Add(searchTerm.Trim());
                query = query.Replace(searchTerm, " ");
            }
            sandoQueryDescription.SearchTerms = sandoQueryDescription.SearchTerms.Distinct().ToList();
            return(query);
        }
Пример #3
0
        private static string ParseNormalSearchTerms(string query, SandoQueryDescription sandoQueryDescription)
        {
            query = Regex.Replace(query, InvalidCharactersRegex, " ");
            var wordSplitter = new WordSplitter();

            //add unsplit words
            var splitTerms = query.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string term in splitTerms)
            {
                sandoQueryDescription.SearchTerms.Add(term.Trim());
            }

            var searchTerms = wordSplitter.ExtractWords(query).Where(w => !String.IsNullOrWhiteSpace(w) && !splitTerms.Contains("-"+w)).OrderByDescending(s => s.Length);
            foreach (var searchTerm in searchTerms)
            {
                sandoQueryDescription.SearchTerms.Add(searchTerm.Trim());
                query = query.Replace(searchTerm, " ");
            }
            sandoQueryDescription.SearchTerms = sandoQueryDescription.SearchTerms.Distinct().ToList();
            return query;
        }
Пример #4
0
        private static string ParseNormalSearchTerms(string query, SandoQueryDescription sandoQueryDescription)
        {
            query = Regex.Replace(query, InvalidCharactersRegex, " ");
            //ensure non-split query terms are added too.
            var nonSplitTerms = query.Split(' ');
            foreach (var nonSplit in nonSplitTerms)
            {
                if(!String.Empty.Equals(nonSplit))
                    sandoQueryDescription.SearchTerms.Add(nonSplit.Trim());
            }
            var wordSplitter = new WordSplitter();
            var searchTerms = wordSplitter.ExtractWords(query).Where(w => !String.IsNullOrWhiteSpace(w));
            foreach (var searchTerm in searchTerms)
            {
                sandoQueryDescription.SearchTerms.Add(searchTerm.Trim());
                query = query.Replace(searchTerm, " ");
            }

            sandoQueryDescription.SearchTerms = sandoQueryDescription.SearchTerms.Distinct().ToList();
            return query;
        }