public Engine(bool auto_data_analysing) { AutoDataAnalysing = auto_data_analysing; this.Db = Fhr.ProductOffice.Models.DbApi.Create(); Dbc = Bot.DbConnection.Create(Fhr.ProductOffice.Models.DbApi.GetProviderConnectionString()); Companies = new Companies(this); Products = new Products(this); CompanyPairs = new ProductIdentifier.CompanyPairs(this); }
void analyse_link(int[] linked_product_ids) { lock (this) { for (int i = 0; i < linked_product_ids.Length; i++) { for (int j = i + 1; j < linked_product_ids.Length; j++) { int product1_id = linked_product_ids[i]; int product2_id = linked_product_ids[j]; Product product1 = Products.Get(product1_id); Product product2 = Products.Get(product2_id); CompanyPairs.MapCategories(product1, product2); //Dictionary<Field, HashSet<string>> matched_words = new Dictionary<Field, HashSet<string>>(); ////matched_words[Field.Category] = new HashSet<string>(); ////foreach (string word in product1.Words(Field.Category)) //// if (product2.Words2Count(Field.Category).ContainsKey(word)) //// matched_words[Field.Category].Add(word); //matched_words[Field.Name] = new HashSet<string>(); //foreach (string word in product1.Words(Field.Name)) // if (product2.Words2Count(Field.Name).ContainsKey(word)) // matched_words[Field.Name].Add(word); //List<ProductLink> pls = create_identical_Product_list_for_training(product1_id, product2.DbProduct.CompanyId); //foreach (ProductLink pl in pls) //{ // if (null != pl.Product2s.Where(x => x.DbProduct.Id == product2_id).FirstOrDefault()) // break; // foreach (Product p2 in pl.Product2s) // { // if (product1_id == p2.DbProduct.Id) // continue; // Dictionary<Field, List<string>> mws = pl.Get(product1_id, p2.DbProduct.Id).MatchedWords; // //List<string> week_mws = mws[Field.Category].Where(x => !matched_words[Field.Category].Contains(x)).ToList(); // //foreach (string word in week_mws) // //{ // // Configuration.Get(product1).SetWordWeight(word, 0.9 * Configuration.Get(product1).GetWordWeight(word)); // // Configuration.Get(product2).SetWordWeight(word, 0.9 * Configuration.Get(product2).GetWordWeight(word)); // //} // List<string> week_mws = mws[Field.Name].Where(x => !matched_words[Field.Name].Contains(x)).ToList(); // foreach (string word in week_mws) // { // Configuration.Company c1 = Configuration.Get(product1); // c1.SetWordWeight(word, 0.9 * c1.GetWordWeight(word)); // Configuration.Company c2 = Configuration.Get(product2); // c2.SetWordWeight(word, 0.9 * c2.GetWordWeight(word)); // } // } //} } } } }
public void save_after_self_training(bool update_traning_time = true) { Cliver.Bot.DbSettings.Delete(Dbc, SettingsKey.SCOPE, "%"); Companies.All.ToList().ForEach(x => { x.SaveWordWeights(); x.SaveSynonyms(); }); CompanyPairs.SaveAfterSelfTraining(); if (update_traning_time) { Cliver.Bot.DbSettings.Save(Dbc, SettingsKey.SCOPE, SettingsKey.TRAINING_TIME, DateTime.Now); } }
public void prepare_for_self_training() { CompanyPairs.PrepareForSelfTraining(); }