10 struct NGram
: public std::map
<std::string
, long> {
11 NGram(const std::string
&file
) {
12 std::ifstream
f(file
.c_str());
15 for(std::string gram
; f
>> frequency
;) {
16 f
.get(); // drop one space
17 getline(f
, gram
); // get rest of line
19 this->insert(make_pair(gram
, frequency
));
27 /*int main(int argc, char **argv) {
30 cerr << "Usage: " << argv[0] << " <filename>" << endl;
34 NGram ngrams(argv[1]);
36 for(NGram::const_iterator it = ngrams.begin();
37 it != ngrams.end(); ++it) {
38 cout << it->first << " " << it->second << endl;