Пример #1
0
        private string QueryExpansion(string input)
        /*Expand the query from original word to synonym word list based on WORDNET library*/
        {
            string[] delim  = { " " };
            string[] words  = input.Split(delim, StringSplitOptions.RemoveEmptyEntries);
            Regex    rgx    = new Regex("[^a-zA-z]");
            string   result = input;

            foreach (string word in words)
            {
                //get expansion here
                List <string> synonyms = LuceneSearch_app.GetSynonym(stemmer.stemTerm(rgx.Replace(word, "")));
                string        temp     = "";

                foreach (string synonym in synonyms)
                {
                    temp += " " + synonym;
                }

                if (word.StartsWith("\""))
                {
                    result += temp;
                }
                else
                {
                    result = result.Replace(word, (word + "^10" + temp));
                }
            }


            return(result);
        }