-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTripletImporter.cpp
More file actions
45 lines (40 loc) · 1.25 KB
/
TripletImporter.cpp
File metadata and controls
45 lines (40 loc) · 1.25 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
/*
* TripletImporter.cpp
*
* Created on: 13.02.2013
* Author: Christoph Schaefer
*/
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <fstream>
#include <dirent.h>
#include <string.h>
#include "TripletImporter.h"
#include "PartitionManager.h"
#include "util.h"
TripletImporter::TripletImporter(const PartitionManagerPtr& partitionManager) :
_partitionManager(partitionManager)
{
}
void TripletImporter::startImport(const std::string& path){
std::string source;
std::string target;
float score;
uint64_t linesSeen(0);
StringVecPtr filenames = util::getAllItemsInDir(path);
for(auto& filename : *filenames) {
std::ifstream file (path + filename);
std::cout << "reading file : " << path + filename << std::endl;
for(std::string line; getline(file, line);) {
++linesSeen;
std::istringstream ss(line);
ss >> source >> target >> score;
_partitionManager->addSourceTargetScore(source, target, score);
}
//std::cout << "rows: " << _partitionManager->getRowCount() << std::endl;
}
_partitionManager->flushSourceTargetScore();
// std::cout << "Successfully " << _partitionManager->getRowCount() << " rows imported, skiped "
// << linesSeen - _partitionManager->getRowCount() << " rows." << std::endl;
}