98 Star 188 Fork 96

lewsn2008/LBTSE

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
CrtForwardIdx.cpp 1008 Bytes
一键复制 编辑 原始数据 按行查看 历史
///////////////////////////////////////////////////////////////////////////
// LB_c: 倒排文件索引(或称:反向索引)
//./ForwardDocIdx Tianwang.raw.2559638448.seg > moon.fdx
#include <iostream>
#include <fstream>
using namespace std;
const string SEPARATOR("/ "); // delimiter between words
int main(int argc, char* argv[])
{
ifstream ifsImgInfo(argv[1]);
if (!ifsImgInfo) {
cerr << "Cannot open " << argv[1] << " for input\n";
return -1;
}
string strLine,strDocNum;
int cnt = 0;
while (getline(ifsImgInfo, strLine)) {
string::size_type idx;
cnt++;
if (cnt%2 == 1){
strDocNum = strLine.substr(0,strLine.size());
continue;
}
if (strLine[0]=='\0' || strLine[0]=='#' || strLine[0]=='\n'){
continue;
}
while ( (idx = strLine.find(SEPARATOR)) != string::npos ) {
string tmp1 = strLine.substr(0,idx);
cout << tmp1 << "\t" << strDocNum << endl;
strLine = strLine.substr(idx + SEPARATOR.size());
}
//if (cnt==100) break;
}
return 0;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/lewsn2008/LBTSE.git
git@gitee.com:lewsn2008/LBTSE.git
lewsn2008
LBTSE
LBTSE
master

搜索帮助