关键词过滤器
关键词过滤器有两个功能:一个是多关键词组合功能并去掉重复项;一个是查找遗漏的关键词
核心代码:
组合功能:
//组合
UpdateData(TRUE);
CString space = _T(""); //间隔
CString firstKeyword = _T("");
CString resualt=_T("");
CString sencondKeyword = _T("");
if(mSpace.GetCheck()==BST_CHECKED)
{
space=_T(" "); //空格
}
int lineCount=0; //前项的行数
int slineCount = mKeyword2.GetLineCount(); //获得后项的行数
if(lineCount>0)
{
//MessageBox(sencondKeyword);
}
lineCount = mKeyword1.GetLineCount(); //获得前项的行数
int i,j;
for(j=0;j<slineCount;j++)
{
int slen = mKeyword2.LineLength(mKeyword2.LineIndex(j));
mKeyword2.GetLine(j,sencondKeyword.GetBuffer(slen),slen);
sencondKeyword.ReleaseBuffer(slen);
for(i=0;i<lineCount;i++)
{
int len = mKeyword1.LineLength(mKeyword1.LineIndex(i));
mKeyword1.GetLine(i,firstKeyword.GetBuffer(len),len);
//MessageBox(_T("行")+);
firstKeyword.ReleaseBuffer(len);
if(firstKeyword != sencondKeyword)
{
resualt = resualt+firstKeyword+space+sencondKeyword+_T("\r\n");
}
}
}
//MessageBox(resualt);
SetDlgItemText(IDC_EDIT3, resualt);
UpdateData(TRUE);
CString space = _T(""); //间隔
CString firstKeyword = _T("");
CString resualt=_T("");
CString sencondKeyword = _T("");
if(mSpace.GetCheck()==BST_CHECKED)
{
space=_T(" "); //空格
}
int lineCount=0; //前项的行数
int slineCount = mKeyword2.GetLineCount(); //获得后项的行数
if(lineCount>0)
{
//MessageBox(sencondKeyword);
}
lineCount = mKeyword1.GetLineCount(); //获得前项的行数
int i,j;
for(j=0;j<slineCount;j++)
{
int slen = mKeyword2.LineLength(mKeyword2.LineIndex(j));
mKeyword2.GetLine(j,sencondKeyword.GetBuffer(slen),slen);
sencondKeyword.ReleaseBuffer(slen);
for(i=0;i<lineCount;i++)
{
int len = mKeyword1.LineLength(mKeyword1.LineIndex(i));
mKeyword1.GetLine(i,firstKeyword.GetBuffer(len),len);
//MessageBox(_T("行")+);
firstKeyword.ReleaseBuffer(len);
if(firstKeyword != sencondKeyword)
{
resualt = resualt+firstKeyword+space+sencondKeyword+_T("\r\n");
}
}
}
//MessageBox(resualt);
SetDlgItemText(IDC_EDIT3, resualt);
查找遗漏:
//查找遗漏关键词
UpdateData(TRUE);
CString firstKeyword = _T("");
CString resualt=_T("");
CString sencondKeyword = _T("");
int lineCount=0; //前项的行数
int slineCount = mKeyword2.GetLineCount(); //获得后项的行数
if(lineCount>0)
{
//MessageBox(sencondKeyword);
}
lineCount = mKeyword1.GetLineCount(); //获得前项的行数
int i,j;
for(j=0;j<lineCount;j++)
{
int len = mKeyword1.LineLength(mKeyword1.LineIndex(j));
mKeyword1.GetLine(j,firstKeyword.GetBuffer(len),len);
firstKeyword.ReleaseBuffer(len);
for(i=0;i<slineCount;i++)
{
int slen = mKeyword2.LineLength(mKeyword2.LineIndex(i));
mKeyword2.GetLine(i,sencondKeyword.GetBuffer(slen),slen);
//MessageBox(_T("行")+);
sencondKeyword.ReleaseBuffer(slen);
if(firstKeyword != sencondKeyword)
{
resualt = resualt+firstKeyword+_T("\r\n");
}
else
{
txtKeyword1.Replace(firstKeyword+_T("\r\n"),_T(""));
/*txtKeyword2.Replace(sencondKeyword+_T("\r\n"),_T(""));
UpdateData(TRUE);*/
}
}
}
//MessageBox(resualt);
SetDlgItemText(IDC_EDIT3, txtKeyword1);
UpdateData(TRUE);
CString firstKeyword = _T("");
CString resualt=_T("");
CString sencondKeyword = _T("");
int lineCount=0; //前项的行数
int slineCount = mKeyword2.GetLineCount(); //获得后项的行数
if(lineCount>0)
{
//MessageBox(sencondKeyword);
}
lineCount = mKeyword1.GetLineCount(); //获得前项的行数
int i,j;
for(j=0;j<lineCount;j++)
{
int len = mKeyword1.LineLength(mKeyword1.LineIndex(j));
mKeyword1.GetLine(j,firstKeyword.GetBuffer(len),len);
firstKeyword.ReleaseBuffer(len);
for(i=0;i<slineCount;i++)
{
int slen = mKeyword2.LineLength(mKeyword2.LineIndex(i));
mKeyword2.GetLine(i,sencondKeyword.GetBuffer(slen),slen);
//MessageBox(_T("行")+);
sencondKeyword.ReleaseBuffer(slen);
if(firstKeyword != sencondKeyword)
{
resualt = resualt+firstKeyword+_T("\r\n");
}
else
{
txtKeyword1.Replace(firstKeyword+_T("\r\n"),_T(""));
/*txtKeyword2.Replace(sencondKeyword+_T("\r\n"),_T(""));
UpdateData(TRUE);*/
}
}
}
//MessageBox(resualt);
SetDlgItemText(IDC_EDIT3, txtKeyword1);
可执行文件见:http://hn911.download.csdn.net/