-
Notifications
You must be signed in to change notification settings - Fork 0
/
Combiner.cpp
51 lines (35 loc) · 1.06 KB
/
Combiner.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
//
// Created by amanda on 07/12/18.
//
#include "Combiner.h"
std::map<std::string, std::vector<int>*>* Combiner::combineResult(const std::string &filename) {
std::ifstream in("intermidate_map/"+filename);
std::string line;
/** get the word in the first line **/
std::getline(in,line);
std::string word=line.substr(0,line.find(' '));
if (word.find('.')) {
word= word.substr(0,word.find('.'));
}
if (word.find(',')) {
word= word.substr(0,word.find(','));
}
if (word.find(':')) {
word= word.substr(0,word.find(':'));
}
/** convert word to lower case **/
std::transform(word.begin(), word.end(), word.begin(), ::tolower);
auto *v = new std::vector<int>();
v->emplace_back(
std::stoi(line.substr(line.find(' ')+1))
);
while (std::getline(in,line)){
v->emplace_back(
std::stoi(line.substr(line.find(' ')+1))
);
}
auto *p=new std::map<std::string, std::vector<int>*>();
p->operator[](word)=v;
in.close();
return p;
}