diff options
author | Patrick Simianer <p@simianer.de> | 2011-10-20 02:31:25 +0200 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2011-10-20 02:31:25 +0200 |
commit | a5a92ebe23c5819ed104313426012011e32539da (patch) | |
tree | 3416818c758d5ece4e71fe522c571e75ea04f100 /utils/phmt.cc | |
parent | b88332caac2cbe737c99b8098813f868ca876d8b (diff) | |
parent | 78baccbb4231bb84a456702d4f574f8e601a8182 (diff) |
finalized merge
Diffstat (limited to 'utils/phmt.cc')
-rw-r--r-- | utils/phmt.cc | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/utils/phmt.cc b/utils/phmt.cc new file mode 100644 index 00000000..48d9f093 --- /dev/null +++ b/utils/phmt.cc @@ -0,0 +1,40 @@ +#include "config.h" + +#ifndef HAVE_CMPH +int main() { + return 0; +} +#else + +#include <iostream> +#include "weights.h" +#include "fdict.h" + +using namespace std; + +int main(int argc, char** argv) { + if (argc != 2) { cerr << "Usage: " << argv[0] << " file.mphf\n"; return 1; } + FD::EnableHash(argv[1]); + cerr << "Number of keys: " << FD::NumFeats() << endl; + cerr << "LexFE = " << FD::Convert("LexFE") << endl; + cerr << "LexEF = " << FD::Convert("LexEF") << endl; + { + vector<weight_t> v(FD::NumFeats()); + v[FD::Convert("LexFE")] = 1.0; + v[FD::Convert("LexEF")] = 0.5; + cerr << "Writing...\n"; + Weights::WriteToFile("weights.bin", v); + cerr << "Done.\n"; + } + { + vector<weight_t> v(FD::NumFeats()); + cerr << "Reading...\n"; + Weights::InitFromFile("weights.bin", &v); + cerr << "Done.\n"; + assert(v[FD::Convert("LexFE")] == 1.0); + assert(v[FD::Convert("LexEF")] == 0.5); + } +} + +#endif + |