示例#1
0
        public static string GetKeyWordsSplitBySpace(string keywords, PanGuTokenizer ktTokenizer)
        {
            StringBuilder          result = new StringBuilder();
            ICollection <WordInfo> words  = ktTokenizer.SegmentToWordInfos(keywords);

            foreach (WordInfo word in words)
            {
                if (word == null)
                {
                    continue;
                }
                result.AppendFormat("{0}^{1}.0 ", word.Word, (int)Math.Pow(3, word.Rank));
            }
            return(result.ToString().Trim());
        }
示例#2
0
        /// <summary>
        /// 盘古分词
        /// </summary>
        /// <param name="keywords">分词关键字</param>
        /// <returns>分词后的字符</returns>
        /// <remarks>2013-3-8 杨浩 创建</remarks>
        public static string Participle(string keywords)
        {
            StringBuilder  result              = new StringBuilder();
            PanGuTokenizer ktTokenizer         = new PanGuTokenizer();
            ICollection <PanGu.WordInfo> words = ktTokenizer.SegmentToWordInfos(keywords);

            if (words.Count != 0)
            {
                _keyword = words.Max().Word;//记录用户查询关键字
            }
            foreach (var word in words.Where(word => word != null))
            {
                result.AppendFormat("{0}^{1}.0 ", word.Word, (int)Math.Pow(3, word.Rank));
            }
            return(result.ToString().Trim());
        }
示例#3
0
        private static string GetKeyWordsSplitBySpace(string keywords, PanGuTokenizer ktTokenizer)
        {
            StringBuilder result = new StringBuilder();
            /*执行分词操作 一个关键字可以拆分为多个次和单个字*/
            ICollection <WordInfo> words = ktTokenizer.SegmentToWordInfos(keywords);

            foreach (WordInfo word in words)
            {
                if (word == null)
                {
                    continue;
                }

                result.AppendFormat("{0}/", word.Word);
            }

            return(result.ToString().Trim());
        }
示例#4
0
        /// <summary>
        /// 字符串分词
        /// </summary>
        /// <param name="keywords">字符串</param>
        /// <param name="ktTokenizer">分词</param>
        /// <returns></returns>
        public string GetKeyWordsSplitFilter(string keywords, PanGuTokenizer ktTokenizer)
        {
            //  拆分字符串
            List <string>          list  = new List <string>();
            ICollection <WordInfo> words = ktTokenizer.SegmentToWordInfos(keywords);

            foreach (WordInfo word in words)
            {
                if (word == null)
                {
                    continue;
                }
                else if (word.Word.Length > 1 && !list.Contains(word.Word))
                {
                    list.Add(word.Word);
                }
            }
            return(string.Join(" ", list.ToArray()));
        }