Welcome to mirror list, hosted at ThFree Co, Russian Federation.

main.cpp « console_sloynik - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 88130e0db8ab58db4741f1b645bdb2301e3a48d9 (plain)
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
#include "../words/slof_dictionary.hpp"
#include "../coding/file_reader.hpp"
#include "../base/logging.hpp"
#include "../std/iostream.hpp"
#include "../std/scoped_ptr.hpp"
#include "../3party/gflags/src/gflags/gflags.h"

DEFINE_string(dictionary, "", "Path to the dictionary.");
DEFINE_string(lookup, "", "Word to lookup.");

int main(int argc, char * argv [])
{
  google::ParseCommandLineFlags(&argc, &argv, false);

  scoped_ptr<sl::SlofDictionary> m_pDic;
  if (!FLAGS_dictionary.empty())
  {
    m_pDic.reset(new sl::SlofDictionary(new FileReader(FLAGS_dictionary)));
    cout << "Keys in the dictionary: " << m_pDic->KeyCount() << endl;
  }

  if (!FLAGS_lookup.empty())
  {
    CHECK(m_pDic.get(), ("Dictionary should not be empty."));
    for (sl::Dictionary::Id i = 0; i < m_pDic->KeyCount(); ++i)
    {
      string key;
      m_pDic->KeyById(i, key);
      if (key == FLAGS_lookup)
      {
        cout << "===== Found id " << i << " =====" << endl;
        string article;
        m_pDic->ArticleById(i, article);
        cout << article << endl;
        cout << "================================" << endl;
      }
    }
  }
}