|
|
|
#pragma once |
|
|
|
#include <boost/thread.hpp> |
|
#include <boost/unordered_map.hpp> |
|
|
|
#include "ug_typedefs.h" |
|
#include "ug_bitext_jstats.h" |
|
#include "moses/thread_safe_container.h" |
|
|
|
namespace sapt |
|
{ |
|
struct |
|
pstats |
|
{ |
|
typedef boost::unordered_map<uint64_t, SPTR<pstats> > map_t; |
|
typedef Moses::ThreadSafeContainer<uint64_t, SPTR<pstats>, map_t> cache_t; |
|
typedef std::vector<unsigned char> alnvec; |
|
typedef boost::unordered_map<uint64_t, jstats> trg_map_t; |
|
typedef boost::unordered_map<uint32_t,uint32_t> indoc_map_t; |
|
#if UG_BITEXT_TRACK_ACTIVE_THREADS |
|
static ThreadSafeCounter active; |
|
#endif |
|
mutable boost::mutex lock; |
|
mutable boost::condition_variable ready; |
|
|
|
size_t raw_cnt; |
|
size_t sample_cnt; |
|
size_t good; |
|
size_t sum_pairs; |
|
size_t in_progress; |
|
|
|
uint32_t ofwd[LRModel::NONE+1]; |
|
uint32_t obwd[LRModel::NONE+1]; |
|
|
|
indoc_map_t indoc; |
|
trg_map_t trg; |
|
bool track_sids; |
|
pstats(bool const track_sids); |
|
~pstats(); |
|
void release(); |
|
void register_worker(); |
|
size_t count_workers() { return in_progress; } |
|
|
|
size_t |
|
add(uint64_t const pid, |
|
float const w, |
|
float const b, |
|
alnvec const& a, |
|
uint32_t const cnt2, |
|
uint32_t fwd_o, |
|
uint32_t bwd_o, |
|
int const docid, |
|
uint32_t const sid); |
|
|
|
void |
|
count_sample(int const docid, |
|
size_t const num_pairs, |
|
int const po_fwd, |
|
int const po_bwd); |
|
void wait() const; |
|
}; |
|
|
|
} |
|
|
|
|