Marc Kupietz | 3400aa5 | 2018-06-05 10:28:55 +0200 | [diff] [blame] | 1 | #include <typeinfo> |
| 2 | #include <assert.h> |
| 3 | #include <memory> |
| 4 | #include <iostream> |
| 5 | #include <stdint.h> |
Marc Kupietz | c2e4321 | 2021-03-13 18:05:14 +0100 | [diff] [blame] | 6 | #include "../src/collocatordb.h" |
Marc Kupietz | 3400aa5 | 2018-06-05 10:28:55 +0200 | [diff] [blame] | 7 | #include <thread> |
| 8 | #include <chrono> |
| 9 | #include <sstream> // for ostringstream |
| 10 | |
| 11 | using namespace rocksdb; |
| 12 | |
| 13 | |
| 14 | int 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 | } |