📄 inverted_demo.cpp
字号:
/* @author: yuanlv 2008/10/14 in HIT
* inverted file demo 1
* This demo just accepts english words.
* 倒排文件原理
* read test data from file.
*/
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <fstream>
#include "inverted_demo.h"
using namespace std;
void get_tids();
//void segment(string &str, vector<string> &v_words);
//void count_frq(map<string, int> &, vector<string> &);
int main()
{
vector<string> v_words; //store word in data file
get_tids(); //segment words, v_words for lidong
map<string,int> map_str;
//count_frq(map_str, v_words);
//print result
for(map<string,int>::iterator iter = map_str.begin();
iter != map_str.end();
++iter)
{
cout << iter->first << " " << iter->second << endl;
}
return 0;
}
void get_tids() //调用HzstrSeg.cpp vector<string> &v_words
{
size_t pos; //for string position index
string temp;
// for((pos = (str.find_first_of(" ", pos))) != string::npos)
//{
// temp = str.substr();
// }
//now ,read data from file
string filename;
cout << "input data name:(eg. 1.txt) " << endl;
cin >> filename;
segment(filename);
}
/*
void count_frq(map<string, int> &map_str, vector<string> &v_words)
{
for(vector<string>::iterator iter = v_words.begin();
iter != v_words.end();
++iter)
{
++map_str[(*iter)]; //count frq of each word
}
}
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -