typedef struct
{
}rule;
/*
anything,send me email
datamining@163.com my QQ 275869936
It comes from
http://blog.sina.com.cn/dataminer321
*/
辅助函数1:
/*
函数调用举例:
m_strSource="a|b|c";//输入参数
substr="|";
//输入参数
vector<string> vItem;
GetItemsFromString(m_strSource,vItem,substr);
vItem[0]="a";
//输出参数
vItem[1]="b";
vItem[2]="c";
*/
void GetItemsFromString(string &m_strSource,vector<string> &vItem,string substr)
{
vItem.clear();
int j;
int i=m_strSource.find(substr,0);
if (i==-1)
{
//m_strSource is a Item
vItem.push_back(m_strSource);
}
else
{
string m_strTemp=m_strSource.substr(0,i);
vItem.push_back(m_strTemp);
while(i!=-1)
{
j=m_strSource.find(substr,i+1);
if(j==-1)
{
m_strTemp=m_strSource.substr(i+1,m_strSource.size()-i-1);
vItem.push_back(m_strTemp);
}
else
{
m_strTemp=m_strSource.substr(i+1,j-i-1);
vItem.push_back(m_strTemp);
}
i=j;
} //end of while
}//end of else
}
{
}
辅助函数2:判断候选项集v1是否在事务v2中
bool IsIn(const vector<string> &v1,const vector<string> &v2)
{
}
有了这两个数据结构和辅助函数,相信你能够设计出你的关联规则挖掘算法。