diff options
author | Barry Haddow <barry.haddow@gmail.com> | 2012-06-01 16:42:00 +0400 |
---|---|---|
committer | Barry Haddow <barry.haddow@gmail.com> | 2012-06-01 16:42:00 +0400 |
commit | 7a78e2d0f794cadaffe549bd278441e44e43e9a6 (patch) | |
tree | 496c31b9e9199882dcd4c79a38f724c8b3767aa7 /misc | |
parent | a7964e02abccba838e7db1c4bdcebb65edb53c74 (diff) |
Add option just to give counts
Diffstat (limited to 'misc')
-rw-r--r-- | misc/queryPhraseTable.cpp | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/misc/queryPhraseTable.cpp b/misc/queryPhraseTable.cpp index d056e83a5..053d932ef 100644 --- a/misc/queryPhraseTable.cpp +++ b/misc/queryPhraseTable.cpp @@ -18,6 +18,7 @@ int main(int argc, char **argv) int nscores = 5; std::string ttable = ""; bool useAlignments = false; + bool reportCounts = false; for(int i = 1; i < argc; i++) { if(!strcmp(argv[i], "-n")) { @@ -28,8 +29,11 @@ int main(int argc, char **argv) if(i + 1 == argc) usage(); ttable = argv[++i]; - } else if(!strcmp(argv[i], "-a")) + } else if(!strcmp(argv[i], "-a")) { useAlignments = true; + } else if (!strcmp(argv[i], "-c")) { + reportCounts = true; + } else usage(); } @@ -54,22 +58,26 @@ int main(int argc, char **argv) else ptree.GetTargetCandidates(srcphrase, tgtcands); - for(uint i = 0; i < tgtcands.size(); i++) { - std::cout << line << " |||"; - for(uint j = 0; j < tgtcands[i].first.size(); j++) - std::cout << ' ' << *tgtcands[i].first[j]; - std::cout << " |||"; - - if(useAlignments) { - std::cout << " " << wordAlignment[i] << " |||"; + if (reportCounts) { + std::cout << line << " " << tgtcands.size() << "\n"; + } else { + for(uint i = 0; i < tgtcands.size(); i++) { + std::cout << line << " |||"; + for(uint j = 0; j < tgtcands[i].first.size(); j++) + std::cout << ' ' << *tgtcands[i].first[j]; + std::cout << " |||"; + + if(useAlignments) { + std::cout << " " << wordAlignment[i] << " |||"; + } + + for(uint j = 0; j < tgtcands[i].second.size(); j++) + std::cout << ' ' << tgtcands[i].second[j]; + std::cout << '\n'; } - - for(uint j = 0; j < tgtcands[i].second.size(); j++) - std::cout << ' ' << tgtcands[i].second[j]; std::cout << '\n'; } - std::cout << '\n'; std::cout.flush(); } } @@ -78,6 +86,7 @@ void usage() { std::cerr << "Usage: queryPhraseTable [-n <nscores>] [-a] -t <ttable>\n" "-n <nscores> number of scores in phrase table (default: 5)\n" + "-c only report counts of entries\n" "-a binary phrase table contains alignments\n" "-t <ttable> phrase table\n"; exit(1); |