Esempio n. 1
0
        /// <summary>
        /// 为keyword做盘古分词
        /// </summary>
        /// <param name="keyword"></param>
        /// <param name="luceneQuery"></param>
        /// <returns></returns>
        private static string AnalyzerKeyword(string keyword)
        {
            StringBuilder  queryStringBuilder = new StringBuilder();
            ILuceneAnalyze analyzer           = new LuceneAnalyze();

            string[] words = analyzer.AnalyzerKey(keyword);
            if (words.Length == 1)
            {
                queryStringBuilder.AppendFormat("{0}:{1}* ", "title", words[0]);
            }
            else
            {
                StringBuilder fieldQueryStringBuilder = new StringBuilder();
                foreach (string word in words)
                {
                    queryStringBuilder.AppendFormat("{0}:{1} ", "title", word);
                }
            }
            string result = queryStringBuilder.ToString().TrimEnd();

            logger.Info(string.Format("AnalyzerKeyword 将 keyword={0}转换为{1}", keyword, result));
            return(result);
        }
Esempio n. 2
0
        private static string AnalyzerKeyword(string keyword)
        {
            StringBuilder  queryStringBuilder = new StringBuilder();
            ILuceneAnalyze analyzer           = new LuceneAnalyze();
            List <string>  words = analyzer.AnalyzerKey(keyword, "title");

            if (words.Count == 1)
            {
                queryStringBuilder.AppendFormat("{0}:{1}* ", "title", words[0]);
            }
            else
            {
                StringBuilder fieldQueryStringBuilder = new StringBuilder();
                foreach (string word in words)
                {
                    queryStringBuilder.AppendFormat("{0}:{1} ", "title", word);
                }
            }
            string result = queryStringBuilder.ToString().TrimEnd();

            Console.WriteLine("AnalyzerKeyword 将 keyword={0}转换为{1}", keyword, result);
            return(result);
        }
Esempio n. 3
0
        /// <summary>
        /// 为keyword做盘古分词
        /// </summary>
        /// <param name="keyword"></param>
        /// <param name="fieldName"></param>
        /// <returns></returns>
        private static string AnalyzerKeyword(string keyword, string fieldName)
        {
            StringBuilder  queryStringBuilder = new StringBuilder();
            ILuceneAnalyze analyzer           = new LuceneAnalyze();
            List <string>  words = analyzer.AnalyzerKey(keyword, fieldName);

            if (words.Count == 1)
            {
                queryStringBuilder.AppendFormat("{0}:{1}* ", fieldName, words[0]);
            }
            else
            {
                StringBuilder fieldQueryStringBuilder = new StringBuilder();
                foreach (string word in words)
                {
                    queryStringBuilder.AppendFormat("{0}:{1} ", fieldName, word);
                }
            }
            string result = queryStringBuilder.ToString().TrimEnd();

            m_logger.Info(string.Format("AnalyzerKeyword 将 keyword={0}转换为{1}", keyword, result));

            return(result);
        }
Esempio n. 4
0
        public static List <string> PanGuSplitWord(string fieldName, string keyword)
        {
            ILuceneAnalyze luceneAnalyze = new LuceneAnalyze();

            return(luceneAnalyze.AnalyzerKey(fieldName, keyword));
        }