File size: 1,100 Bytes
1ce325b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef KENLM_INTERPOLATE_SPLIT_WORKER_H_
#define KENLM_INTERPOLATE_SPLIT_WORKER_H_

#include "../../util/stream/chain.hh"
#include "../../util/stream/stream.hh"

namespace lm {
namespace interpolate {

class SplitWorker {
  public:
    /**
     * Constructs a split worker for a particular order. It writes the
     * split-off backoff values to the backoff chain and the ngram id and
     * probability to the sort chain for each ngram in the input.
     */
    SplitWorker(std::size_t order, util::stream::Chain &backoff_chain,
                util::stream::Chain &sort_chain);

    /**
     * The callback invoked to handle the input from the ngram intermediate
     * files.
     */
    void Run(const util::stream::ChainPosition& position);

  private:
    /**
     * The ngram order we are reading/writing for.
     */
    std::size_t order_;

    /**
     * The stream to write to for the backoff values.
     */
    util::stream::Stream backoff_input_;

    /**
     * The stream to write to for the ngram id + probability values.
     */
    util::stream::Stream sort_input_;
};
}
}
#endif