Beispiel #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Loading queries...");
            WordProcessor.BuildWordGraph("train");
            Console.WriteLine("Building words connections...");
            ////WordProcessor.FindConnections();
            WordProcessor.BuildGlobalEquGraph();
            WordProcessor.BuildLocalEquGraph();
            Console.WriteLine("Initializing CF model...");
            CF.Initialize();
            Console.WriteLine("Initialization finishd!");

            Console.WriteLine("Begin Query");
            SkuSelector.Query();
            Console.WriteLine("All things have been done!");

            Console.ReadLine();
        }
Beispiel #2
0
        /// <summary>
        /// 根据搜索词确定产品关联度
        /// </summary>
        /// <param name="sku">产品编号</param>
        /// <param name="query">用户输入的查询</param>
        /// <returns>关联度打分</returns>
        public static double GetSkuQuerySim(string sku, string query)
        {
            double score = 0;

            string[] words = WordProcessor.GetCorrectQuery(sku, query);
            var      dict  = WordProcessor.skuKeywords[sku];

            for (int i = 0; i < words.Length; ++i)
            {
                if (dict.ContainsKey(words[i]))
                {
                    score += GetWordPairScore(dict, sku, words[i]);
                    if (i > 0)
                    {
                        var node = dict[words[i]];
                        if (node.pre.Contains(words[i - 1]))
                        {
                            score += COMBO_BONUS;
                        }
                    }
                }
            }
            return(score);
        }