-
Notifications
You must be signed in to change notification settings - Fork 0
/
sift_txt2vec.cpp
59 lines (56 loc) · 1.11 KB
/
sift_txt2vec.cpp
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
59
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <cstring>
#include <string>
using namespace std;
int main()
{
ifstream fin_vec;
fin_vec.open("vector.txt",ios::in);
char* tmp = new char[3400];
float* tmp_vec;
map<string,float*>dic;
map<string,float*>::iterator it;
/*fin_vec.getline(tmp,3400);//pass the first line
int have=0;
while(fin_vec>>tmp)
{
tmp_vec = new float[200];
//printf("%s\n",tmp);
for(int i = 0;i<200;i++)
{
fin_vec>>tmp_vec[i];
}
dic.insert(pair<string,float*>(tmp,tmp_vec));
}*/
fin_vec.close();
fin_vec.open("sift_lines.txt",ios::in);
ofstream fout;
fout.open("vec_result.txt",ios::out);
while(fin_vec>>tmp)
{
cout<<tmp;
getchar();
if(tmp[0]=='E'){fout<<endl;continue;}
it=dic.find(tmp);
if(it!=dic.end())
{
for(int i = 0;i<200;i++)
fout<<it->second[i]<<' ';
fout<<endl;
//getchar();
}
}
fin_vec.close();
fout.close();
/*fout.close();
ofstream fout1;
fout1.open("dic.txt",ios::out);
for(it=dic.begin();it!=dic.end();it++)
fout1<<it->first<<' '<<it->second<<endl;
fout1.close();*/
return 0;
}