13 #include <boost/program_options.hpp>
15 #include <Poco/String.h>
16 #include <Poco/SharedPtr.h>
17 #include <Poco/StringTokenizer.h>
25 namespace po = boost::program_options;
28 int main(
int ac,
char** av) {
29 bool ret = EXIT_FAILURE;
33 po::options_description desc(
"Supported options");
35 (
"help",
"produce help message")
36 (
"input_file,i", po::value<std::string>(),
"Input file")
37 (
"lang,l", po::value<std::string>(),
"Input language")
38 (
"verbose,v", po::value(&verbose)->zero_tokens()->default_value(
false),
"verbose mode")
39 (
"check,c", po::value(&check)->zero_tokens()->default_value(
false),
"verbose mode")
40 (
"detect,d", po::value(&detect)->zero_tokens()->default_value(
false),
"verbose mode")
44 po::store(po::parse_command_line(ac, av, desc), vm);
48 if (vm.count(
"help")) {
49 std::cout << desc <<
"\n";
52 if(ret==EXIT_SUCCESS) {
54 if (vm.count(
"input_file") && vm.count(
"lang")) {
55 std::ifstream iss(vm[
"input_file"].as<std::string>());
56 while(iss.good() && !iss.eof()) {
66 if(detectLang!=vm[
"lang"].as<std::string>()) {
67 std::cout <<
"Error: " << word <<
'\t' << detectLang <<
std::endl;
73 std::cout <<
"Input file or language was not set.\n";
76 if (vm.count(
"input_file")) {
77 std::ifstream iss(vm[
"input_file"].as<std::string>());
78 std::map<std::string, unsigned int> mapLang;
79 std::map<std::string, std::vector<std::string> > mapWordsByLang;
80 while(iss.good() && !iss.eof()) {
93 for(std::map<std::string, unsigned int>::const_iterator it=mapLang.begin(); it!=mapLang.end(); ++it) {
94 std::cout << it->first <<
'\t' << it->second <<
std::endl;
95 for(std::vector<std::string>::const_iterator itr=mapWordsByLang[it->first].begin(); itr!=mapWordsByLang[it->first].end(); ++itr) {
100 std::cout <<
"-------------------------------------------" <<
std::endl;
104 std::cout <<
"Input file was not set.\n";
109 std::string content(std::istreambuf_iterator<char>(std::cin), std::istreambuf_iterator<char>());
119 std::map<WORD_CONTENT_OFFSET, WORD_LENGTH>::const_iterator it1;
120 for( it1=lCData._mapOffsets.begin(); it1!=lCData._mapOffsets.end(); ++it1) {