return;
size_t startPos = 0;
- while((startPos = str.find(from, startPos)) != std::string::npos) {
+ while ((startPos = str.find(from, startPos)) != std::string::npos) {
str.replace(startPos, from.length(), to);
startPos += to.length();
}
std::string consequentCategory)
{
SingleCategoryItemIdFilter itemIdFilter(consequentCategory, itemCatalogue);
- BasketFilter::filter_in_place(initBaskets,itemIdFilter);
+ BasketFilter::filter_in_place(initBaskets, itemIdFilter);
std::list<Basket> compressedBaskets = BasketCompressor::compress(initBaskets);
public:
static std::list<AssocRuleOfIds> generate_rules(
- const std::list<std::pair<ItemIdSet,double>> &freqItemIdSets,
+ const std::list<std::pair<ItemIdSet, double>> &freqItemIdSets,
const IItemIdFilter &itemIdFilter,
double minConfidence);
static AssocRuleOfIds rule_template(const ItemIdSet &sourceItemIdSet, const IItemIdFilter &antecedentItemIdFilter);
private:
- static double supportOf(const std::list<std::pair<ItemIdSet,double>> &allFreqItemIdSets, const ItemIdSet &wanted);
+ static double supportOf(const std::list<std::pair<ItemIdSet, double>> &allFreqItemIdSets, const ItemIdSet &wanted);
};
std::list<ctx::Basket> ctx::BasketCompressor::compress(const std::list<ctx::Basket>& inputBaskets)
{
- std::map<std::string,Basket> basketsMap;
+ std::map<std::string, Basket> basketsMap;
// TODO: maybe it is worth to resign from string keys and use std::map<ItemSet,weight> instead.
for (const Basket& basket : inputBaskets) {
auto findResult = basketsMap.find(itemSetStr);
if (findResult == basketsMap.end()) {
- basketsMap.insert(std::pair<std::string,Basket>(itemSetStr, basket));
+ basketsMap.insert(std::pair<std::string, Basket>(itemSetStr, basket));
} else {
Basket& compressedBasket = findResult->second;
compressedBasket.weight += basket.weight;
int ctx::ItemCatalogue::id_of(const ctx::Item& item)
{
std::string s = ItemStringConverter::item_to_string(item);
- std::map<std::string,int>::iterator it = mItemIdsOfStrings.find(s);
+ std::map<std::string, int>::iterator it = mItemIdsOfStrings.find(s);
if (it == mItemIdsOfStrings.end()) { // new item
mMaxId++;
mItemIdsOfStrings[s] = mMaxId;
private:
/* Translates item string to its id */
- std::map<std::string,int> mItemIdsOfStrings;
+ std::map<std::string, int> mItemIdsOfStrings;
/* Translating category string to int */
- std::map<std::string,std::set<int>> mCategoryItemIds;
+ std::map<std::string, std::set<int>> mCategoryItemIds;
/* Stores item strings (index is item's id) */
std::vector<std::string> mItemStrings;
double support = basketAgregator.supportOf(candidate);
if (support >= supportThreshold) {
freqItemsetsOfCurrSize.push_back(candidate);
- allFreqItemsets.push_back(std::make_pair(candidate,support));
+ allFreqItemsets.push_back(std::make_pair(candidate, support));
}
}
candidates = find_wider_candidates(freqItemsetsOfCurrSize, ++candidateSize);
static bool survives_prunning(ItemIdSet &widerCandidate, const std::list<ItemIdSet> &narrowFreqSets);
/* Find frequent itemsets along with its support value. */
- static std::list<std::pair<ItemIdSet,double>> find_frequent_itemid_sets(BasketsAgregator &basketAgregator, double supportThreshold);
+ static std::list<std::pair<ItemIdSet, double>> find_frequent_itemid_sets(BasketsAgregator &basketAgregator, double supportThreshold);
private:
static std::list<ItemIdSet> single_size_candidates(BasketsAgregator &basketAgregator);
__dbManager.insert(0, SOCIAL_TABLE_CONTACT_LOG, data, NULL);
- } while(contacts_list_next(list) == CONTACTS_ERROR_NONE);
+ } while (contacts_list_next(list) == CONTACTS_ERROR_NONE);
}
void ctx::ContactLogAggregator::__removeExpiredLog()