/// <summary> /// 获取关键词的指数以及最相关的类目信息,从WebService中获取 /// </summary> /// <param name="itemTitle">宝贝标题,用来计算关键词的相似度,权重0.3</param> /// <param name="strMainWord">核心词,用来计算关键词的相似度,权重1</param> /// <param name="lstword">需要预测的关键词列表ID</param> public static List <EntityWordData> GetkeywordIndexFromWs(string itemTitle, string strMainWord, List <string> lstword) { //存储结果集 var resultLst = new List <EntityWordData>(); string strKeywords = string.Join(",", lstword.ToArray()); WService.FindWord.EntityWordBase[] arrWordBase = wsFindWordProxy.KeywordBaseLongTimeCache(strKeywords); if (arrWordBase == null) { return(null); } //int intWordIndex = 0; //排序过滤后再计算序号,否则序号呈现给前台后不连续很难看 foreach (var wordBase in arrWordBase) { EntityWordData itemWord = new EntityWordData(); if (wordBase.reord_base != null && wordBase.reord_base.Count() > 0) { //itemWord.id = ++intWordIndex; itemWord.word = wordBase.word; var wordIndex = wordBase.reord_base[0]; itemWord.impressions = wordIndex.impression; itemWord.click = wordIndex.click; itemWord.ctr = string.IsNullOrEmpty(wordIndex.ctr) ? 0 : Convert.ToDouble(wordIndex.ctr); itemWord.cpc = wordIndex.avg_price; itemWord.competition = wordIndex.competition; itemWord.cost = wordIndex.cost; itemWord.directpay = wordIndex.directpay; itemWord.directpaycount = wordIndex.directpaycount; itemWord.favitemcount = wordIndex.favitemcount; itemWord.favshopcount = wordIndex.favshopcount; itemWord.indirectpay = wordIndex.indirectpay; itemWord.indirectpaycount = wordIndex.indirectpaycount; itemWord.rate = string.IsNullOrEmpty(wordIndex.rate) ? 0 : Convert.ToDouble(wordIndex.rate); itemWord.roi = string.IsNullOrEmpty(wordIndex.roi) ? 0 : Convert.ToDouble(wordIndex.roi); itemWord.totalfavcount = wordIndex.totalfavcount; itemWord.totalpay = wordIndex.totalpay; itemWord.totalpaycount = wordIndex.totalpaycount; //关键词相似度 char[] arrItemWord = itemWord.word.ToCharArray(); double matchDegree = strMainWord.ToCharArray().Intersect(arrItemWord).Count() / strMainWord.Length * 1.0D + 0.1D * (itemTitle.ToCharArray().Intersect(arrItemWord).Count()); itemWord.similar = Math.Round(matchDegree, 2); resultLst.Add(itemWord); } } return(resultLst.OrderByDescending(o => o.impressions).OrderByDescending(o => Convert.ToDecimal(o.similar)).ToList()); }
/// <summary> /// 获取关键词的指数以及最相关的类目信息,从WebService中获取 /// </summary> /// <param name="lstword">需要预测的关键词列表</param> public static List <EntityWordData> GetkeywordIndexFromWs(List <string> lstword) { //存储结果集 var resultLst = new List <EntityWordData>(); string strKeywords = string.Join(",", lstword.ToArray()); WService.FindWord.EntityWordBase[] arrWordBase = wsFindWordProxy.KeywordBaseLongTimeCache(strKeywords); if (arrWordBase == null) { return(null); } //int intWordIndex = 0; foreach (var wordBase in arrWordBase) { EntityWordData itemWord = new EntityWordData(); if (wordBase.reord_base != null && wordBase.reord_base.Count() > 0) { //itemWord.id = ++intWordIndex; itemWord.word = wordBase.word; var wordIndex = wordBase.reord_base[0]; itemWord.impressions = wordIndex.impression; itemWord.click = wordIndex.click; itemWord.ctr = string.IsNullOrEmpty(wordIndex.ctr) ? 0 : Convert.ToDouble(wordIndex.ctr); itemWord.cpc = wordIndex.avg_price; itemWord.competition = wordIndex.competition; itemWord.cost = wordIndex.cost; itemWord.directpay = wordIndex.directpay; itemWord.directpaycount = wordIndex.directpaycount; itemWord.favitemcount = wordIndex.favitemcount; itemWord.favshopcount = wordIndex.favshopcount; itemWord.indirectpay = wordIndex.indirectpay; itemWord.indirectpaycount = wordIndex.indirectpaycount; itemWord.rate = string.IsNullOrEmpty(wordIndex.rate) ? 0 : Convert.ToDouble(wordIndex.rate); itemWord.roi = string.IsNullOrEmpty(wordIndex.roi) ? 0 : Convert.ToDouble(wordIndex.roi); itemWord.totalfavcount = wordIndex.totalfavcount; itemWord.totalpay = wordIndex.totalpay; itemWord.totalpaycount = wordIndex.totalpaycount; resultLst.Add(itemWord); } } return(resultLst); }