FITKMS_business.Util.RecommendationService.GetTopArticleMatches C# (CSharp) Метод

GetTopArticleMatches() публичный Метод

public GetTopArticleMatches ( int articleId, int userId ) : List
articleId int
userId int
Результат List
        public List<fsp_Clanci_SelectById_Result> GetTopArticleMatches(int articleId, int userId)
        {
            //Inicijalno ukloniti članke sa lošom prosječnom ocjenom (<2 ako ima više od 5 glasova)
            //Inverse User Frequency fj = log(n/nj) - 0 ako su svi korisnici ocijenili item j
            //Ovakve članke ukloniti iz preporuke?

            GetRatingsForArticles(articleId, userId);
            var sortedList = articleRecommendation.Where(x => x.Key != articleId);
            List<fsp_Clanci_SelectById_Result> recommendations = new List<fsp_Clanci_SelectById_Result>();

            foreach (var entry in sortedList)
            {
                double pearson = CalculatePearsonCorrelationForArticles(articleId, entry.Key);
                //Postaviti minimalnu vrijednost koeficijenta
                if (pearson >= 0.2)
                    recommendations.Add(DAClanci.SelectById(entry.Key));
            }

            return recommendations;
        }

Usage Example

        private void ItemBasedRecommendation()
        {
            DataList articlesList = (DataList)this.Master.FindControl("articlesList");
            RecommendationService recommendation = new RecommendationService();

            //Ukoliko je korisnik prijavljen ukloniti pregledane članke iz preporuke
            int userId = 0;
            if (User.Identity.Name != "")
                userId = Convert.ToInt32(User.Identity.Name);
            articlesList.DataSource = recommendation.GetTopArticleMatches(articleId, userId);
            articlesList.DataBind();
        }