hash generator stub
This commit is contained in:
parent
59ddab3511
commit
7f062c49e4
33
concordia/hash_generator.cpp
Normal file
33
concordia/hash_generator.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
#include "concordia/hash_generator.hpp"
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/archive/binary_oarchive.hpp>
|
||||
#include <boost/archive/binary_iarchive.hpp>
|
||||
#include <boost/serialization/map.hpp>
|
||||
#include <fstream>
|
||||
|
||||
|
||||
HashGenerator::HashGenerator(const string & wordMapFilename) throw(ConcordiaException) {
|
||||
_wordMapFilename = wordMapFilename;
|
||||
if (boost::filesystem::exists(_wordMapFilename)) {
|
||||
ifstream ifs(_wordMapFilename.c_str(), std::ios::binary);
|
||||
boost::archive::binary_iarchive ia(ifs);
|
||||
ia >> _wordMap;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
HashGenerator::~HashGenerator() {
|
||||
}
|
||||
|
||||
vector<int> HashGenerator::generateHash(const string & sentence) {
|
||||
vector<int> result;
|
||||
return result;
|
||||
}
|
||||
|
||||
void HashGenerator::serializeWordMap() {
|
||||
ofstream ofs(_wordMapFilename.c_str(), std::ios::binary);
|
||||
boost::archive::binary_oarchive oa(ofs);
|
||||
oa << _wordMap;
|
||||
}
|
||||
|
||||
|
37
concordia/hash_generator.hpp
Normal file
37
concordia/hash_generator.hpp
Normal file
@ -0,0 +1,37 @@
|
||||
#ifndef HASH_GENERATOR_HDR
|
||||
#define HASH_GENERATOR_HDR
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include "concordia/concordia_config.hpp"
|
||||
|
||||
/*!
|
||||
Class for generating a sentence hash.
|
||||
|
||||
*/
|
||||
|
||||
using namespace std;
|
||||
|
||||
class HashGenerator {
|
||||
public:
|
||||
explicit HashGenerator(const string & wordMapFilename) throw(ConcordiaException);
|
||||
|
||||
/*! Destructor.
|
||||
*/
|
||||
virtual ~HashGenerator();
|
||||
|
||||
vector<int> generateHash(const string & sentence);
|
||||
|
||||
void serializeWordMap();
|
||||
|
||||
private:
|
||||
|
||||
map<int,string> _wordMap;
|
||||
|
||||
string _wordMapFilename;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user