blob: 69a93894a9dc4ba90a72e6c1834dbcf4432a80b8 [file] [log] [blame]
Marc Kupietz3400aa52018-06-05 10:28:55 +02001#include <typeinfo>
2#include <assert.h>
3#include <memory>
4#include <iostream>
5#include <stdint.h>
Marc Kupietzc2e43212021-03-13 18:05:14 +01006#include "../src/collocatordb.h"
Marc Kupietz3400aa52018-06-05 10:28:55 +02007#include <thread>
8#include <chrono>
9#include <sstream> // for ostringstream
10
11using namespace rocksdb;
12
13
14int main(int argc, char** argv) {
15 const int START=0;
16 const int STOP=1500000;
17 int done = 0;
18 CollocatorDB cdb = CollocatorDB(argv[1], true);
19 std::cerr << "Database " << argv[1] << " opened\n";
20
21 #pragma omp parallel for ordered schedule(static,1)
22 for(uint32_t i=START; i< STOP; i++) {
23 // cdb.dumpSparseLlr(i, 5);
24 std::vector<rocksdb::Collocator> cs = cdb.get_collocators(i);
25 std::stringstream stream;
26 // stream << i << "(" << cdb.getWord(i) << "): ";
27 if(cs.empty())
28 stream << "0 0.0";
29 for (rocksdb::Collocator c : cs) {
30 stream << c.w2 << " " << c.npmi << " ";
31 // stream << c.w2 << "(" << cdb.getWord(c.w2) << ") " << c.llr << " ";
32 if(c.raw < 5)
33 break;
34 }
35 stream << "\n";
36 #pragma omp ordered
37 std::cout << stream.str();
38 if(done++ % 100 == 0) {
39 std::cerr <<"\r\033[2K"<<std::flush;
40 std::cerr << "done: " << done * 100.0 / (STOP-START) << "%" <<std::flush;
41 }
42 }
43 std::cout << std::flush;
44}