-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdense_index.cpp
More file actions
58 lines (55 loc) · 1.06 KB
/
dense_index.cpp
File metadata and controls
58 lines (55 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
#include<fstream>
using namespace std;
struct node
{
int docID;
char title;
char infobox;
char link;
char category;
short int text;
};
int main()
{
char word[100000];
ifstream in;
int record_size, string_length;
long long int offset = 0;
ofstream out;
in.open("Index/Final_Index", ios::in | ios::binary);
out.open("Index/Dense_Index", ios::out | ios::binary);
int count = 0;
while(1)
{
if(in.read((char*)&string_length, 4) == 0)
{
break;
}
count++;
in.read(word, string_length);
word[string_length] = '\0';
out.write((char*)&string_length, 4);
out.write(word, string_length);
if(strcmp(word, "preiti") == 0)
cout<<word<<endl;
out.write((char*)&offset, 8);
in.read((char*)&record_size, 4);
offset = offset + 4 + string_length + 4 + record_size*10;
in.seekg(record_size*10, ios::cur);
}
cout<<count<<endl;
out.close();
in.close();
return 0;
}