41 #include "../proto/dataio.h"
42 #include "../proto/model.pb.h"
43 #include "../utils/kdebug.h"
46 using confusion_learning::SymbolMessage;;
49 int main(
int argc,
char* argv[]) {
51 bool output_compressed =
true;
55 while ((option_char = getopt(argc, argv,
"Uo:")) != EOF) {
56 switch (option_char) {
58 output_compressed =
false;
64 cerr <<
"usage: " << argv[0]
65 <<
" [-U] [-o <output file>]"
67 cerr <<
"-U - output to uncompressed file" << endl;
68 cerr <<
"-o - output to filename (otherwise to uncompressed stdout" << endl;
76 ConfusionProtoIO reader;
77 ConfusionProtoIO* writer;
78 if (output_name.empty()) {
79 writer =
new ConfusionProtoIO(
"", ConfusionProtoIO::WRITESTD,
false,
true);
81 writer =
new ConfusionProtoIO(output_name, ConfusionProtoIO::WRITE,
82 output_compressed,
true);
85 SymbolMessage sym_msg;
89 getline(cin, input_data);
90 if (input_data.empty()) {
93 size_t delim_pos = input_data.find(
'\t');
94 if (delim_pos != string::npos) {
95 input_data.erase(delim_pos);
97 sym_msg.set_symbol(input_data);
98 sym_msg.set_index(feature_id);
100 writer->Write(sym_msg);
102 cerr <<
"Wrote " << feature_id <<
" feature messages to file: ";
103 if (output_name.empty()) {
104 cerr <<
" STDOUT " << endl;
106 cerr << output_name.c_str() <<
" " << endl;
int main(int argc, char *argv[])