diff options
author | Yury Melnichek <melnichek@gmail.com> | 2011-03-06 01:12:21 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:12:57 +0300 |
commit | 5d9239a1edede8693c69119e282017d965d2c326 (patch) | |
tree | 2ac33f5cf71ee8f3814de8f2dfe3688e8c3820e1 /console_sloynik | |
parent | a5ad66614265259763a1ed849db7ae8e918e8a3c (diff) |
Add sloynik to omim!! Yea!
Diffstat (limited to 'console_sloynik')
-rw-r--r-- | console_sloynik/console_sloynik.pro | 13 | ||||
-rw-r--r-- | console_sloynik/main.cpp | 39 |
2 files changed, 52 insertions, 0 deletions
diff --git a/console_sloynik/console_sloynik.pro b/console_sloynik/console_sloynik.pro new file mode 100644 index 0000000000..e52a2fff1b --- /dev/null +++ b/console_sloynik/console_sloynik.pro @@ -0,0 +1,13 @@ +TARGET = console_sloynik +TEMPLATE = app +CONFIG += console +CONFIG -= app_bundle + +SLOYNIK_DIR = .. +DEPENDENCIES = gflags bzip2 zlib base coding coding_sloynik words + +include($$SLOYNIK_DIR/sloynik_common.pri) + +SOURCES += main.cpp + +HEADERS += diff --git a/console_sloynik/main.cpp b/console_sloynik/main.cpp new file mode 100644 index 0000000000..56b32f68bd --- /dev/null +++ b/console_sloynik/main.cpp @@ -0,0 +1,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 (int 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; + } + } + } +} |