예제 #1
0
            public ProductPair(Engine engine, Product product1, Product product2)
            {
                this.engine = engine;
                {
                    CategoryScore = engine.CompanyPairs.GetCategoryComparisonScore(product1, product2);
                }
                {
                    Dictionary <string, double> word2name_score = new Dictionary <string, double>();
                    foreach (string word in product1.Words(Field.Name))
                    {
                        if (product2.Words2Count(Field.Name).ContainsKey(word))
                        {
                            word2name_score[word] = .5 * engine.Companies.Get(product1.DbProduct.CompanyId).WordWeight(Field.Name, word)
                                                    + .5 * engine.Companies.Get(product2.DbProduct.CompanyId).WordWeight(Field.Name, word);
                        }
                    }
                    //MatchedWords[Field.Name] = word2name_score.Keys.ToList();
                    if (word2name_score.Count > 0)
                    {
                        NameScore = .5 * ((double)word2name_score.Values.Sum() / word2name_score.Count)
                                    + .25 * ((double)word2name_score.Count / product1.Words(Field.Name).Count)
                                    + .25 * ((double)word2name_score.Count / product2.Words(Field.Name).Count);
                    }
                }
                //    decimal p1 = product1.DbProduct.Price;

                //HashSet<string> matched_words = new HashSet<string>();
                //foreach (string word in product1.Words(Field.Description))
                //{
                //    if (product2.Word2Count(Field.Description).ContainsKey(word))
                //        matched_words.Add(word);
                //}
                //foreach (string word in matched_words)
                //{
                //    double score = get_word_score(word, product1, product2);
                //    SecondaryScore += score;
                //}
            }
예제 #2
0
        double get_category_comparison_score(Product product1, Product product2)
        {
            Dictionary <string, double> word2category_score = new Dictionary <string, double>();

            foreach (string word in product1.Words(Field.Category))
            {
                if (product2.Words2Count(Field.Category).ContainsKey(word))
                {
                    word2category_score[word] = .5 * engine.Companies.Get(product1.DbProduct.CompanyId).WordWeight(Field.Category, word)
                                                + .5 * engine.Companies.Get(product2.DbProduct.CompanyId).WordWeight(Field.Category, word);
                }
            }

            double score = 0;

            if (word2category_score.Count > 0)
            {
                score = .5 * ((double)word2category_score.Values.Sum() / word2category_score.Count)
                        + .25 * ((double)word2category_score.Count / product1.Words(Field.Category).Count)
                        + .25 * ((double)word2category_score.Count / product2.Words(Field.Category).Count);
            }
            score = (do_categories_belong2mapped_ones(product1, product2) ? 1 : 0.3) * score;
            return(score);
        }
예제 #3
0
            public ProductPair(Engine engine, Product product1, Product product2)
            {
                this.engine = engine;
                {
                    CategoryScore = engine.CompanyPairs.GetCategoryComparisonScore(product1, product2);
                }
                {
                    Dictionary<string, double> word2name_score = new Dictionary<string, double>();
                    foreach (string word in product1.Words(Field.Name))
                    {
                        if (product2.Words2Count(Field.Name).ContainsKey(word))
                            word2name_score[word] = .5 * engine.Companies.Get(product1.DbProduct.CompanyId).WordWeight(Field.Name, word)
                                + .5 * engine.Companies.Get(product2.DbProduct.CompanyId).WordWeight(Field.Name, word);
                    }
                    //MatchedWords[Field.Name] = word2name_score.Keys.ToList();
                    if (word2name_score.Count > 0)
                    {
                        NameScore = .5 * ((double)word2name_score.Values.Sum() / word2name_score.Count)
                            + .25 * ((double)word2name_score.Count / product1.Words(Field.Name).Count)
                            + .25 * ((double)word2name_score.Count / product2.Words(Field.Name).Count);
                    }
                }
                //    decimal p1 = product1.DbProduct.Price;

                //HashSet<string> matched_words = new HashSet<string>();
                //foreach (string word in product1.Words(Field.Description))
                //{
                //    if (product2.Word2Count(Field.Description).ContainsKey(word))
                //        matched_words.Add(word);
                //}
                //foreach (string word in matched_words)
                //{
                //    double score = get_word_score(word, product1, product2);
                //    SecondaryScore += score;
                //}
            }
예제 #4
0
        double get_category_comparison_score(Product product1, Product product2)
        {
            Dictionary<string, double> word2category_score = new Dictionary<string, double>();
            foreach (string word in product1.Words(Field.Category))
            {
                if (product2.Words2Count(Field.Category).ContainsKey(word))
                    word2category_score[word] = .5 * engine.Companies.Get(product1.DbProduct.CompanyId).WordWeight(Field.Category, word)
                        + .5 * engine.Companies.Get(product2.DbProduct.CompanyId).WordWeight(Field.Category, word);
            }

            double score = 0;
            if (word2category_score.Count > 0)
            {
                score = .5 * ((double)word2category_score.Values.Sum() / word2category_score.Count)
                    + .25 * ((double)word2category_score.Count / product1.Words(Field.Category).Count)
                    + .25 * ((double)word2category_score.Count / product2.Words(Field.Category).Count);
            }
            score = (do_categories_belong2mapped_ones(product1, product2) ? 1 : 0.3) * score;
            return score;
        }