Index: trunk/apertium/apertium/align.cc =================================================================== --- trunk/apertium/apertium/align.cc (revision 69687) +++ trunk/apertium/apertium/align.cc (revision 69688) @@ -14,8 +14,8 @@ // along with this program; if not, see . #include "align.h" - #include "linebreak.h" +#include #include #include @@ -33,7 +33,7 @@ for (std::vector >::const_iterator i_ = string_.begin(); i_ != string_.end(); ++i_) { - std::cerr << " " << std::setw(width_) << std::left << i_->first + std::wcerr << " " << std::setw(width_) << std::left << i_->first << std::setw(0) << linebreak::linebreak_(i_->second, width_ + 2, width_ + 4) << '\n'; Index: trunk/apertium/apertium/apertium-prelatex.l =================================================================== --- trunk/apertium/apertium/apertium-prelatex.l (revision 69687) +++ trunk/apertium/apertium/apertium-prelatex.l (revision 69688) @@ -10,6 +10,7 @@ #include #include #include +#include extern "C" { #if !defined(__STDC__) @@ -420,9 +421,9 @@ void usage(string const &progname) { - cerr << "USAGE: " << progname << " [input_file [output_file]" << ']' << endl; + wcerr << "USAGE: " << progname << " [input_file [output_file]" << ']' << endl; - cerr << "LaTeX format preprocessor " << endl; + wcerr << "LaTeX format preprocessor " << endl; exit(EXIT_SUCCESS); } Index: trunk/apertium/apertium/apertium_filter_ambiguity.cc =================================================================== --- trunk/apertium/apertium/apertium_filter_ambiguity.cc (revision 69687) +++ trunk/apertium/apertium/apertium_filter_ambiguity.cc (revision 69688) @@ -43,7 +43,7 @@ struct stat var; if(stat(filename, &var)) { - cerr << "Can't stat '" << filename << "'" << endl; + wcerr << "Can't stat '" << filename << "'" << endl; exit(EXIT_FAILURE); } @@ -51,7 +51,7 @@ if(!retval) { - cerr << "Can't open '" << filename << "'" << endl; + wcerr << "Can't open '" << filename << "'" << endl; exit(EXIT_FAILURE); } #ifdef _MSC_VER @@ -67,7 +67,7 @@ if(argc < 2 || argc > 4) { - cerr << "USAGE: " << basename(argv[0]) << " tsx_file [input [output]" << endl; + wcerr << "USAGE: " << basename(argv[0]) << " tsx_file [input [output]" << endl; exit(EXIT_FAILURE); } Index: trunk/apertium/apertium/apertium_interchunk.cc =================================================================== --- trunk/apertium/apertium/apertium_interchunk.cc (revision 69687) +++ trunk/apertium/apertium/apertium_interchunk.cc (revision 69688) @@ -36,14 +36,14 @@ void message(char *progname) { - cerr << "USAGE: " << basename(progname) << " [-tz] t2x preproc [input [output]]" << endl; - cerr << " t2x t2x rules file" << endl; - cerr << " preproc result of preprocess trules file" << endl; - cerr << " input input file, standard input by default" << endl; - cerr << " output output file, standard output by default" << endl; - cerr << "OPTIONS" <")); align::align_(options_description_); - std::cerr << '\n'; + std::wcerr << '\n'; options_description_.clear(); options_description_.push_back(std::make_pair("-w, --sliding-window", "use the Light Sliding Window algorithm")); align::align_(options_description_); - std::cerr << '\n'; + std::wcerr << '\n'; options_description_.clear(); options_description_.push_back(std::make_pair("-g, --tagger", "disambiguate the input")); align::align_(options_description_); - std::cerr << '\n'; + std::wcerr << '\n'; options_description_.clear(); options_description_.push_back(std::make_pair("-r, --retrain=ITERATIONS", "with -u: exit;\notherwise: retrain the tagger with ITERATIONS unsupervised iterations")); options_description_.push_back(std::make_pair("-s, --supervised=ITERATIONS", "with -u: train the tagger with a hand-tagged corpus;\nwith -w: exit;\notherwise: initialise the tagger with a hand-tagged corpus and retrain it with ITERATIONS unsupervised iterations")); options_description_.push_back(std::make_pair("-t, --train=ITERATIONS", "with -u: exit;\notherwise: train the tagger with ITERATIONS unsupervised iterations")); align::align_(options_description_); - std::cerr << '\n'; + std::wcerr << '\n'; options_description_.clear(); options_description_.push_back(std::make_pair("-h, --help", "display this help and exit")); align::align_(options_description_); @@ -679,8 +679,8 @@ FILE_Tagger_.read_dictionary(Dictionary); try_close_file("DICTIONARY", argv[optind], Dictionary); - FILE *TaggedCorpus = try_open_file_utf8("TAGGED_CORPUS", argv[optind + 4], "r"); - FILE *UntaggedCorpus = try_open_file_utf8("UNTAGGED_CORPUS", argv[optind + 5], "r"); + FILE *TaggedCorpus = try_open_file("TAGGED_CORPUS", argv[optind + 4], "r"); + FILE *UntaggedCorpus = try_open_file("UNTAGGED_CORPUS", argv[optind + 5], "r"); FILE_Tagger_.init_probabilities_from_tagged_text_(TaggedCorpus, UntaggedCorpus); try_close_file("TAGGED_CORPUS", argv[optind + 4], TaggedCorpus); @@ -729,7 +729,7 @@ try { apertium_tagger(argc, argv); } catch (const err_Exception &err_Exception_) { - std::cerr << "Try 'apertium-tagger --help' for more information.\n"; + std::wcerr << "Try 'apertium-tagger --help' for more information." << std::endl; return 1; } catch (...) { throw; Index: trunk/apertium/apertium/apertium_tagger_apply_new_rules.cc =================================================================== --- trunk/apertium/apertium/apertium_tagger_apply_new_rules.cc (revision 69687) +++ trunk/apertium/apertium/apertium_tagger_apply_new_rules.cc (revision 69688) @@ -22,6 +22,7 @@ #include #include #include "getopt_long.h" +#include #include #include @@ -38,17 +39,17 @@ void check_file(FILE *f, const string& path) { if (!f) { - cerr<<"Error: cannot open file '"<get_tags()]; if ((k>=tagger_data_hmm.getM())||(k<0)) { - cerr<<"Error: Ambiguity class number out of range: "<get_superficial_form())<<"\n"; - cerr<<"Ambiguity class: "<get_string_tags())<<"\n"; + wcerr<<"Error: Ambiguity class number out of range: "<get_superficial_form())<<"\n"; + wcerr<<"Ambiguity class: "<get_string_tags())<<"\n"; } } @@ -77,15 +77,15 @@ word=lexmorfo.get_next_word(); } - cerr<] < file.crp \n\n"; + wcerr<<"USAGE:\n"; + wcerr<] < file.crp \n\n"; - cerr<<"ARGUMENTS: \n" + wcerr<<"ARGUMENTS: \n" <<" --tsxfile|-x: Specify a tagger specification file\n" <<" --probfile|-p: Specify a tagger parameter file\n" <<" --clength|-l: Specify the length of the corpus to process\n"; @@ -100,12 +100,12 @@ int c; int option_index=0; - cerr<<"LOCALE: "< ", REG_EXTENDED)) { - cerr << "ERROR: Illegal regular expression for escape characters" << endl; + wcerr << "ERROR: Illegal regular expression for escape characters" << endl; exit(EXIT_FAILURE); } } @@ -234,7 +235,7 @@ ", REG_EXTENDED)) { - cerr << "ERROR: Illegal regular expression for tag-names" << endl; + wcerr << "ERROR: Illegal regular expression for tag-names" << endl; exit(EXIT_FAILURE); } } @@ -742,13 +743,13 @@ { - cerr << "USAGE: " << progname << " format_file [input_file [output_file]" << ']' << endl; + wcerr << "USAGE: " << progname << " format_file [input_file [output_file]" << ']' << endl; - cerr << "USAGE: " << progname << " [ -h | -i | -n ] [input_file [output_file]" << ']' << endl; + wcerr << "USAGE: " << progname << " [ -h | -i | -n ] [input_file [output_file]" << ']' << endl; - cerr << " format processor " << endl; + wcerr << " format processor " << endl; exit(EXIT_SUCCESS); } Index: trunk/apertium/apertium/hmm.cc =================================================================== --- trunk/apertium/apertium/hmm.cc (revision 69687) +++ trunk/apertium/apertium/hmm.cc (revision 69688) @@ -539,15 +539,15 @@ i=*itag; for (jtag=pretags.begin(); jtag!=pretags.end(); jtag++) { j=*jtag; - //cerr<<"previous alpha["<1) { @@ -559,8 +559,8 @@ prob = alpha[len][tag]; - //cerr<<"prob="<name << "'" << endl; + wcerr << "Error: unexpected rvalue expression '" << element->name << "'" << endl; exit(EXIT_FAILURE); } @@ -1495,7 +1495,7 @@ break; default: - cerr << "Error: Unknown input token." << endl; + wcerr << "Error: Unknown input token." << endl; return; } } Index: trunk/apertium/apertium/lextor_data.cc =================================================================== --- trunk/apertium/apertium/lextor_data.cc (revision 69687) +++ trunk/apertium/apertium/lextor_data.cc (revision 69688) @@ -110,33 +110,33 @@ void LexTorData::read(FILE *is) { - //cerr<<"LexTorData::read------------------------------------\n"; + //wcerr<<"LexTorData::read------------------------------------\n"; n_stopwords=(WORD_DATA_TYPE)Compression::multibyte_read(is); n_words=(WORD_DATA_TYPE)Compression::multibyte_read(is); n_words_per_set=(WORD_DATA_TYPE)Compression::multibyte_read(is); n_set=(WORD_DATA_TYPE)Compression::multibyte_read(is); - //cerr<::iterator it; for (it=stopwords.begin(); it!=stopwords.end(); it++) { Compression::wstring_write(*it, os); @@ -201,7 +201,7 @@ } //Write the list of words - //cerr<<"list of words----------------------------------------\n"; + //wcerr<<"list of words----------------------------------------\n"; for(unsigned int i=1; i (&prob), sizeof(double)); EndianDoubleUtil::write(os, sum); @@ -228,7 +228,7 @@ it_w_lch_set++) { WORD_DATA_TYPE word=it_w_lch_set->first; COUNT_DATA_TYPE count=it_w_lch_set->second; - //cerr<<" word: "<find(*its)==0) { wcerr<name << "'" << endl; + wcerr << "Error: unexpected rvalue expression '" << element->name << "'" << endl; exit(EXIT_FAILURE); } @@ -1627,7 +1627,7 @@ break; default: - cerr << "Error: Unknown input token." << endl; + wcerr << "Error: Unknown input token." << endl; return; } } Index: trunk/apertium/apertium/reformat.xsl =================================================================== --- trunk/apertium/apertium/reformat.xsl (revision 69687) +++ trunk/apertium/apertium/reformat.xsl (revision 69688) @@ -36,6 +36,7 @@ #include <unistd.h> #include <lttoolbox/lt_locale.h> #include <lttoolbox/ltstr.h> +#include <apertium/string_utils.h> #include <wchar.h> #ifdef _WIN32 #include <io.h> @@ -123,7 +124,7 @@ if(!temp) { - cerr << "ERROR: File '" << filename <<"' not found." << endl; + wcerr << "ERROR: File '" << filename <<"' not found." << endl; exit(EXIT_FAILURE); } while(static_cast<int>(mychar = fgetwc_unlocked(temp)) != EOF) @@ -186,8 +187,8 @@ void usage(string const &progname) { - cerr << "USAGE: " << progname << " [input_file [output_file]" << ']' << endl; - cerr << " format processor " << endl; + wcerr << "USAGE: " << progname << " [input_file [output_file]" << ']' << endl; + wcerr << " format processor " << endl; exit(EXIT_SUCCESS); } Index: trunk/apertium/apertium/string_utils.cc =================================================================== --- trunk/apertium/apertium/string_utils.cc (revision 69687) +++ trunk/apertium/apertium/string_utils.cc (revision 69688) @@ -20,6 +20,7 @@ #include #include #include +#include #ifdef _MSC_VER #define snprintf _snprintf @@ -181,3 +182,10 @@ { return strcmp(s1, s2.c_str()) != 0; } + +std::wostream & operator<<(std::wostream & ostr, std::string const & str) { + std::copy( + str.begin(), str.end(), + std::ostream_iterator(ostr)); + return ostr; +} Index: trunk/apertium/apertium/string_utils.h =================================================================== --- trunk/apertium/apertium/string_utils.h (revision 69687) +++ trunk/apertium/apertium/string_utils.h (revision 69688) @@ -57,4 +57,6 @@ static wstring toupper(wstring const &s); }; +std::wostream & operator<< (std::wostream & ostr, std::string const & str); + #endif Index: trunk/apertium/apertium/tagger_utils.cc =================================================================== --- trunk/apertium/apertium/tagger_utils.cc (revision 69687) +++ trunk/apertium/apertium/tagger_utils.cc (revision 69688) @@ -43,7 +43,7 @@ } void tagger_utils::file_name_error (string const &s) { - cerr << "Error: " << s << endl; + wcerr << "Error: " << s << endl; exit(1); } Index: trunk/apertium/apertium/tmx_aligner_tool.cc =================================================================== --- trunk/apertium/apertium/tmx_aligner_tool.cc (revision 69687) +++ trunk/apertium/apertium/tmx_aligner_tool.cc (revision 69688) @@ -10,6 +10,7 @@ * * *************************************************************************/ #include +#include namespace TMXAligner { @@ -27,7 +28,7 @@ is >> huPos; if (is.peek()!=' ') { - std::cerr << "no space in line" << std::endl; + std::wcerr << "no space in line" << std::endl; throw "data error"; } is.ignore(); @@ -35,7 +36,7 @@ is >> enPos; if (is.peek()!='\n') { - std::cerr << "too much data in line" << std::endl; + std::wcerr << "too much data in line" << std::endl; throw "data error"; } is.ignore(); @@ -98,7 +99,7 @@ enBisentences.push_back( enSentenceListPretty[ bisentenceList[i].second ] ); } -// std::cerr << huBisentences.size() << " bisentences collected." << std::endl; +// std::wcerr << huBisentences.size() << " bisentences collected." << std::endl; } @@ -151,11 +152,11 @@ setSentenceValues( enSentenceList, enLength, alignParameters.utfCharCountingMode ); bool quasiglobal_stopwordRemoval = false; -// std::cerr << "quasiglobal_stopwordRemoval is set to " << quasiglobal_stopwordRemoval << std::endl; +// std::wcerr << "quasiglobal_stopwordRemoval is set to " << quasiglobal_stopwordRemoval << std::endl; if (quasiglobal_stopwordRemoval) { removeStopwords( huSentenceListPretty, enSentenceList ); -// std::cerr << "Stopwords removed." << std::endl; +// std::wcerr << "Stopwords removed." << std::endl; } SentenceList huSentenceListGarbled, enSentenceListGarbled; @@ -185,9 +186,9 @@ if (thickness>maximalThickness) { -// std::cerr << "WARNING: Downgrading planned thickness " << thickness << " to " << maximalThickness ; -// std::cerr << " to obey memory constraint of " << quasiglobal_maximalSizeInMegabytes << " megabytes " << std::endl; -// std::cerr << "You should recompile if you have much more physical RAM than that. People of the near-future, forgive me for the inconvenience." << std::endl; +// std::wcerr << "WARNING: Downgrading planned thickness " << thickness << " to " << maximalThickness ; +// std::wcerr << " to obey memory constraint of " << quasiglobal_maximalSizeInMegabytes << " megabytes " << std::endl; +// std::wcerr << "You should recompile if you have much more physical RAM than that. People of the near-future, forgive me for the inconvenience." << std::endl; thickness = maximalThickness; } @@ -195,20 +196,20 @@ AlignMatrix similarityMatrix( huBookSize, enBookSize, thickness, outsideOfRadiusValue ); sentenceListsToAlignMatrixIdentity( huSentenceListGarbled, enSentenceListGarbled, similarityMatrix ); -// std::cerr << std::endl; -// std::cerr << "Rough translation-based similarity matrix ready." << std::endl; +// std::wcerr << std::endl; +// std::wcerr << "Rough translation-based similarity matrix ready." << std::endl; Trail bestTrail; AlignMatrix dynMatrix( huBookSize+1, enBookSize+1, thickness, 1e30 ); align( similarityMatrix, huLength, enLength, bestTrail, dynMatrix ); -// std::cerr << "Align ready." << std::endl; +// std::wcerr << "Align ready." << std::endl; double globalQuality; globalQuality = globalScoreOfTrail( bestTrail, dynMatrix, huSentenceListGarbled, enSentenceListGarbled ); - // std::cerr << "Global quality of unfiltered align " << globalQuality << std::endl; + // std::wcerr << "Global quality of unfiltered align " << globalQuality << std::endl; if (alignParameters.realignType==AlignParameters::NoRealign) { @@ -221,11 +222,11 @@ if (!success) { -// std::cerr << "Realign zone too close to quasidiagonal border. Abandoning realign. The align itself is suspicious." << std::endl; +// std::wcerr << "Realign zone too close to quasidiagonal border. Abandoning realign. The align itself is suspicious." << std::endl; } else { -// std::cerr << "Border of realign zone determined." << std::endl; +// std::wcerr << "Border of realign zone determined." << std::endl; switch (alignParameters.realignType) { @@ -236,13 +237,13 @@ SentenceList huBisentences,enBisentences; throw "unimplemented"; -// std::cerr << "Plausible bisentences filtered." << std::endl; +// std::wcerr << "Plausible bisentences filtered." << std::endl; modelOne.build(huBisentences,enBisentences); -// std::cerr << "IBM Model I ready." << std::endl; +// std::wcerr << "IBM Model I ready." << std::endl; sentenceListsToAlignMatrixIBMModelOne( huSentenceListPretty, enSentenceList, modelOne, similarityMatrixDetailed ); -// std::cerr << "IBM Model I based similarity matrix ready." << std::endl; +// std::wcerr << "IBM Model I based similarity matrix ready." << std::endl; break; } case AlignParameters::FineTranslationRealign: @@ -249,11 +250,11 @@ { TransLex transLex; transLex.build(dictionary); -// std::cerr << "Hashtable for dictionary ready." << std::endl; +// std::wcerr << "Hashtable for dictionary ready." << std::endl; sentenceListsToAlignMatrixTranslation( huSentenceListPretty, enSentenceList, transLex, similarityMatrixDetailed ); -// std::cerr << "Fine translation-based similarity matrix ready." << std::endl; +// std::wcerr << "Fine translation-based similarity matrix ready." << std::endl; break; } @@ -267,7 +268,7 @@ Trail bestTrailDetailed; AlignMatrix dynMatrixDetailed( huBookSize+1, enBookSize+1, thickness, 1e30 ); align( similarityMatrixDetailed, huLength, enLength, bestTrailDetailed, dynMatrixDetailed ); -// std::cerr << "Detail realign ready." << std::endl; +// std::wcerr << "Detail realign ready." << std::endl; bestTrail = bestTrailDetailed; dynMatrix = dynMatrixDetailed; @@ -275,7 +276,7 @@ globalQuality = globalScoreOfTrail( bestTrail, dynMatrix, huSentenceListGarbled, enSentenceListGarbled ); - // std::cerr << "Global quality of unfiltered align after realign " << globalQuality << std::endl; + // std::wcerr << "Global quality of unfiltered align after realign " << globalQuality << std::endl; } } @@ -284,27 +285,27 @@ if ( alignParameters.postprocessTrailQualityThreshold != -1 ) { postprocessTrail( bestTrail, trailScoresInterval, alignParameters.postprocessTrailQualityThreshold ); -// std::cerr << "Trail start and end postprocessed by score." << std::endl; +// std::wcerr << "Trail start and end postprocessed by score." << std::endl; } if ( alignParameters.postprocessTrailStartAndEndQualityThreshold != -1 ) { postprocessTrailStartAndEnd( bestTrail, trailScoresInterval, alignParameters.postprocessTrailStartAndEndQualityThreshold ); -// std::cerr << "Trail start and end postprocessed by score." << std::endl; +// std::wcerr << "Trail start and end postprocessed by score." << std::endl; } if ( alignParameters.postprocessTrailByTopologyQualityThreshold != -1 ) { postprocessTrailByTopology( bestTrail, alignParameters.postprocessTrailByTopologyQualityThreshold ); -// std::cerr << "Trail postprocessed by topology." << std::endl; +// std::wcerr << "Trail postprocessed by topology." << std::endl; } bool quasiglobal_spaceOutBySentenceLength = true; -// std::cerr << "quasiglobal_spaceOutBySentenceLength is set to " << quasiglobal_spaceOutBySentenceLength << std::endl; +// std::wcerr << "quasiglobal_spaceOutBySentenceLength is set to " << quasiglobal_spaceOutBySentenceLength << std::endl; if (quasiglobal_spaceOutBySentenceLength) { spaceOutBySentenceLength( bestTrail, huSentenceListPretty, enSentenceList, alignParameters.utfCharCountingMode ); -// std::cerr << "Trail spaced out by sentence length." << std::endl; +// std::wcerr << "Trail spaced out by sentence length." << std::endl; } // In cautious mode, auto-aligned rundles are thrown away if @@ -312,13 +313,13 @@ if (alignParameters.cautiousMode) { cautiouslyFilterTrail( bestTrail ); -// std::cerr << "Trail filtered by topology." << std::endl; +// std::wcerr << "Trail filtered by topology." << std::endl; } globalQuality = globalScoreOfTrail( bestTrail, dynMatrix, huSentenceListGarbled, enSentenceListGarbled ); - // std::cerr << "Global quality of unfiltered align after realign " << globalQuality << std::endl; + // std::wcerr << "Global quality of unfiltered align after realign " << globalQuality << std::endl; bool textual = ! alignParameters.justSentenceIds ; @@ -428,17 +429,17 @@ std::ifstream hus(huFilename.c_str()); SentenceList huSentenceListPretty; huSentenceListPretty.readNoIds( hus ); -// std::cerr << huSentenceListPretty.size() << " hungarian sentences read." << std::endl; +// std::wcerr << huSentenceListPretty.size() << " hungarian sentences read." << std::endl; std::ifstream ens(enFilename.c_str()); SentenceList enSentenceList; enSentenceList.readNoIds( ens ); -// std::cerr << enSentenceList.size() << " english sentences read." << std::endl; +// std::wcerr << enSentenceList.size() << " english sentences read." << std::endl; if ( (enSentenceList. size() < huSentenceListPretty.size()/5) || (huSentenceListPretty.size() < enSentenceList. size()/5) ) { -// std::cerr << "Sizes differing too much. Ignoring files to avoid a rare loop bug." << std::endl; +// std::wcerr << "Sizes differing too much. Ignoring files to avoid a rare loop bug." << std::endl; return; } @@ -447,7 +448,7 @@ /* double globalQuality = */alignerToolWithObjects ( dictionary, huSentenceListPretty, enSentenceList, alignParameters, std::cout ); -// std::cerr << "Quality " << globalQuality << std::endl ; +// std::wcerr << "Quality " << globalQuality << std::endl ; } else @@ -457,7 +458,7 @@ ( dictionary, huSentenceListPretty, enSentenceList, alignParameters, os ); // If you want to collect global quality information in batch mode, grep "^Quality" of stderr must do. -// std::cerr << "Quality\t" << outputFilename << "\t" << globalQuality << std::endl ; +// std::wcerr << "Quality\t" << outputFilename << "\t" << globalQuality << std::endl ; } } @@ -473,7 +474,7 @@ void main_alignerToolUsage() { - std::cerr << "Usage (either):\n\ + std::wcerr << "Usage (either):\n\ alignerTool [ common_arguments ] [ -hand=hand_align_file ] dictionary_file source_text target_text\n\ \n\ or:\n\ @@ -585,8 +586,8 @@ if (batchMode && (remains.size()!=2) ) { - std::cerr << "Batch mode requires exactly two file arguments." << std::endl; - std::cerr << std::endl; + std::wcerr << "Batch mode requires exactly two file arguments." << std::endl; + std::wcerr << std::endl; main_alignerToolUsage(); throw "argument error"; @@ -597,7 +598,7 @@ { if (batchMode) { - std::cerr << "-batch and -" << handArgumentname << " are incompatible switches." << std::endl; + std::wcerr << "-batch and -" << handArgumentname << " are incompatible switches." << std::endl; throw "argument error"; } else @@ -607,7 +608,7 @@ if (alignParameters.handAlignFilename.empty()) { - std::cerr << "-" << handArgumentname << " switch requires a filename value." << std::endl; + std::wcerr << "-" << handArgumentname << " switch requires a filename value." << std::endl; throw "argument error"; } } @@ -618,7 +619,7 @@ { if (batchMode) { - std::cerr << "-batch and -" << autoDictDumpArgumentname << " are incompatible switches." << std::endl; + std::wcerr << "-batch and -" << autoDictDumpArgumentname << " are incompatible switches." << std::endl; throw "argument error"; } else @@ -628,7 +629,7 @@ if (alignParameters.autoDictionaryDumpFilename.empty()) { - std::cerr << "-" << autoDictDumpArgumentname << " switch requires a filename value." << std::endl; + std::wcerr << "-" << autoDictDumpArgumentname << " switch requires a filename value." << std::endl; throw "argument error"; } } @@ -636,8 +637,8 @@ if (!batchMode && (remains.size()!=3) ) { - std::cerr << "Nonbatch mode requires exactly three file arguments." << std::endl; - std::cerr << std::endl; + std::wcerr << "Nonbatch mode requires exactly three file arguments." << std::endl; + std::wcerr << std::endl; main_alignerToolUsage(); throw "argument error"; @@ -649,13 +650,13 @@ } catch (...) { - std::cerr << std::endl; + std::wcerr << std::endl; main_alignerToolUsage(); throw "argument error"; } -// std::cerr << "Reading dictionary..." << std::endl; +// std::wcerr << "Reading dictionary..." << std::endl; const char* dicFilename = remains[0] ; DictionaryItems dictionary; std::ifstream dis(dicFilename); @@ -676,7 +677,7 @@ if (words.size()!=3) { - std::cerr << "Batch file has incorrect format." << std::endl; + std::wcerr << "Batch file has incorrect format." << std::endl; throw "data error"; } @@ -685,7 +686,7 @@ enFilename = words[1]; outFilename = words[2]; -// std::cerr << "Processing " << outFilename << std::endl; +// std::wcerr << "Processing " << outFilename << std::endl; bool failed = false; try { @@ -693,23 +694,23 @@ } catch ( const char* errorType ) { - std::cerr << errorType << std::endl; + std::wcerr << errorType << std::endl; failed = true; } catch ( std::exception& e ) { - std::cerr << "some failed assertion:" << e.what() << std::endl; + std::wcerr << "some failed assertion:" << e.what() << std::endl; failed = true; } catch ( ... ) { - std::cerr << "some unknown failed assertion..." << std::endl; + std::wcerr << "some unknown failed assertion..." << std::endl; failed = true; } if (failed) { - std::cerr << "Align failed for " << outFilename << std::endl; + std::wcerr << "Align failed for " << outFilename << std::endl; } } } @@ -724,17 +725,17 @@ #ifndef _DEBUG catch ( const char* errorType ) { - std::cerr << errorType << std::endl; + std::wcerr << errorType << std::endl; return -1; } catch ( std::exception& e ) { - std::cerr << "some failed assertion:" << e.what() << std::endl; + std::wcerr << "some failed assertion:" << e.what() << std::endl; return -1; } catch ( ... ) { - std::cerr << "some unknown failed assertion..." << std::endl; + std::wcerr << "some unknown failed assertion..." << std::endl; return -1; } #endif Index: trunk/apertium/apertium/tmx_alignment.cc =================================================================== --- trunk/apertium/apertium/tmx_alignment.cc (revision 69687) +++ trunk/apertium/apertium/tmx_alignment.cc (revision 69688) @@ -13,6 +13,7 @@ #include // For SentenceList #include // For FrequencyMap +#include #include #include @@ -20,7 +21,7 @@ #include // Copypaste-elve. TODO Elhelyezni. -#define massert(e) if (!(e)) { std::cerr << #e << " failed" << std::endl; throw "assert"; } +#define massert(e) if (!(e)) { std::wcerr << #e << " failed" << std::endl; throw "assert"; } std::ostream& operator<<( std::ostream& os, std::pair p ) { @@ -240,7 +241,7 @@ bool logging = false; - if (logging) std::cerr << std::endl; + if (logging) std::wcerr << std::endl; bool over = false; bool hopelesslyBadTrail = false; @@ -303,7 +304,7 @@ if (logging) { - std::cerr << huPos << " \t" << enPos << std::endl; + std::wcerr << huPos << " \t" << enPos << std::endl; } } @@ -313,7 +314,7 @@ bestTrail.clear(); bestTrail.push_back(std::make_pair(huBookSize,enBookSize)); bestTrail.push_back(std::make_pair(0,0)); - std::cerr << "Error: hopelessly bad trail." << std::endl; + std::wcerr << "Error: hopelessly bad trail." << std::endl; } std::reverse(bestTrail.begin(), bestTrail.end() ); @@ -334,11 +335,11 @@ buildDynProgMatrix( w, huLength, enLength, v, trellis ); -// std::cerr << "Matrix built." << std::endl; +// std::wcerr << "Matrix built." << std::endl; trelliToLadder( trellis, bestTrail ); -// std::cerr << "Trail found." << std::endl; +// std::wcerr << "Trail found." << std::endl; } @@ -382,10 +383,10 @@ { int score = countIntersectionOfTrails( trailAuto, trailHand ); - std::cerr << trailAuto.size()-score << " misaligned out of " << trailHand.size() << " correct items, " + std::wcerr << trailAuto.size()-score << " misaligned out of " << trailHand.size() << " correct items, " << trailAuto.size() << " bets." << std::endl; - std::cerr << "Precision: " << 1.0*score/trailAuto.size() + std::wcerr << "Precision: " << 1.0*score/trailAuto.size() << ", Recall: " << 1.0*score/trailHand.size() << std::endl; double ratio = 1.0*(trailAuto.size()-score)/trailAuto.size(); @@ -493,7 +494,7 @@ } } - std::cerr << numberOfEvaluatedItems << " items inside the border." << std::endl; + std::wcerr << numberOfEvaluatedItems << " items inside the border." << std::endl; } return true; Index: trunk/apertium/apertium/tmx_arguments_parser.cc =================================================================== --- trunk/apertium/apertium/tmx_arguments_parser.cc (revision 69687) +++ trunk/apertium/apertium/tmx_arguments_parser.cc (revision 69688) @@ -10,6 +10,7 @@ * * *************************************************************************/ #include +#include #include #include @@ -26,7 +27,7 @@ std::string p = argv[i]; if (p.empty() || p[0]!='-') { - std::cerr << p << ": unable to parse argument\n"; + std::wcerr << p << ": unable to parse argument\n"; throw "argument error"; return false; } @@ -34,7 +35,7 @@ if (p.empty()) { - std::cerr << "Empty argument\n"; + std::wcerr << "Empty argument\n"; throw "argument error"; return false; } @@ -85,7 +86,7 @@ if (p.empty()) { - std::cerr << "Empty argument\n"; + std::wcerr << "Empty argument\n"; throw "argument error"; return false; } @@ -123,13 +124,13 @@ const_iterator it=find(name); if (it==end()) { - // std::cerr << "Argument -" << name << " missing.\n"; + // std::wcerr << "Argument -" << name << " missing.\n"; return false; } if (it->second.kind != AnyData::Int) { - std::cerr << "Argument -" << name << ": integer expected.\n"; + std::wcerr << "Argument -" << name << ": integer expected.\n"; throw "argument error"; } @@ -148,7 +149,7 @@ } else if (! it->second.dString.empty()) { - std::cerr << "Argument -" << name << ": value is not allowed.\n"; + std::wcerr << "Argument -" << name << ": value is not allowed.\n"; return false; } else @@ -178,7 +179,7 @@ } else { - std::cerr << "No value is allowed for argument -" << name << ".\n"; + std::wcerr << "No value is allowed for argument -" << name << ".\n"; throw "argument error"; } } @@ -187,16 +188,16 @@ { if (!empty()) { - std::cerr << "Invalid argument: "; + std::wcerr << "Invalid argument: "; for ( Arguments::const_iterator it=begin(); it!=end(); ++it ) { - std::cerr << "-" << it->first; + std::wcerr << "-" << it->first; if (!it->second.dString.empty()) - std::cerr << "=" << it->second.dString; - std::cerr << " "; + std::wcerr << "=" << it->second.dString; + std::wcerr << " "; } - std::cerr << std::endl; + std::wcerr << std::endl; throw "argument error"; } Index: trunk/apertium/apertium/tmx_book_to_matrix.cc =================================================================== --- trunk/apertium/apertium/tmx_book_to_matrix.cc (revision 69687) +++ trunk/apertium/apertium/tmx_book_to_matrix.cc (revision 69688) @@ -185,7 +185,7 @@ if (!rarelyLogging || (huPos%100==0)) { - // std::cerr << huPos << " "; + // std::wcerr << huPos << " "; } } } @@ -255,7 +255,7 @@ if (!rarelyLogging || (huPos%100==0)) { - // std::cerr << huPos << " (" << numberOfEvaluatedItems << ") "; + // std::wcerr << huPos << " (" << numberOfEvaluatedItems << ") "; } } } @@ -301,7 +301,7 @@ if (!rarelyLogging || (huPos%100==0)) { - // std::cerr << huPos << " "; + // std::wcerr << huPos << " "; } } } Index: trunk/apertium/apertium/tmx_dic_tree.h =================================================================== --- trunk/apertium/apertium/tmx_dic_tree.h (revision 69687) +++ trunk/apertium/apertium/tmx_dic_tree.h (revision 69688) @@ -106,7 +106,7 @@ if ( ( v->id != 0 ) && ( id != 0 ) ) { if (WarnOnConflict) - std::cerr << "warning: conflict in tree" << std::endl; + std::wcerr << "warning: conflict in tree" << std::endl; } if ( id != 0 ) { @@ -165,7 +165,7 @@ else { if (DicTree::WarnOnConflict) - std::cerr << "warning: conflict in tree" << std::endl; + std::wcerr << "warning: conflict in tree" << std::endl; } } Index: trunk/apertium/apertium/tmx_dictionary.cc =================================================================== --- trunk/apertium/apertium/tmx_dictionary.cc (revision 69687) +++ trunk/apertium/apertium/tmx_dictionary.cc (revision 69688) @@ -22,7 +22,7 @@ #include -#define massert(e) if (!(e)) { std::cerr << #e << " failed" << std::endl; throw "assert"; } +#define massert(e) if (!(e)) { std::wcerr << #e << " failed" << std::endl; throw "assert"; } namespace TMXAligner { @@ -151,7 +151,7 @@ split( line, halfs ); if (halfs.size()!=2) { - std::cerr << "Incorrect bicorpus file: " << halfs.size() << " records in line " << huSentenceList.size() << std::endl; + std::wcerr << "Incorrect bicorpus file: " << halfs.size() << " records in line " << huSentenceList.size() << std::endl; throw "data error"; } @@ -565,7 +565,7 @@ ++ignored; } } - std::cerr << added << " items added to TransLex, " << ignored << " multiword items ignored." << std::endl; + std::wcerr << added << " items added to TransLex, " << ignored << " multiword items ignored." << std::endl; } TransLex::DictInterval TransLex::lookupLeftWord ( const Word& huWord ) const Index: trunk/apertium/apertium/tmx_trail_postprocessors.cc =================================================================== --- trunk/apertium/apertium/tmx_trail_postprocessors.cc (revision 69687) +++ trunk/apertium/apertium/tmx_trail_postprocessors.cc (revision 69688) @@ -280,7 +280,7 @@ { if (global_postprocessLogging) { - std::cerr << "Thrown away at position " << pos + std::wcerr << "Thrown away at position " << pos << ", avarage " << avg << ", threshold " << qualityThreshold << std::endl; } @@ -319,7 +319,7 @@ { if (global_postprocessLogging) { - std::cerr << "Thrown away at position " << pos + std::wcerr << "Thrown away at position " << pos << ", avarage " << avg << ", threshold " << qualityThreshold << std::endl; } @@ -365,7 +365,7 @@ { if (global_postprocessLogging) { - std::cerr << "Thrown away at position " << pos + std::wcerr << "Thrown away at position " << pos << ", avarage " << avg << ", threshold " << qualityThreshold << std::endl; } @@ -404,7 +404,7 @@ { if (global_postprocessLogging) { - std::cerr << "Thrown away at position " << pos + std::wcerr << "Thrown away at position " << pos << ", avarage " << avg << std::endl; } Index: trunk/apertium/apertium/tmx_translate.cc =================================================================== --- trunk/apertium/apertium/tmx_translate.cc (revision 69687) +++ trunk/apertium/apertium/tmx_translate.cc (revision 69688) @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -33,7 +34,7 @@ if (hu.size()==1) { dumbDictionary[ hu[0] ] = en ; - // std::cerr << hu[0] << "\t" << en << std::endl; + // std::wcerr << hu[0] << "\t" << en << std::endl; } } } @@ -97,7 +98,7 @@ { std::ifstream is( dictionaryFilename.c_str() ); dictionary.read( is ); - std::cerr << dictionary.size() << " dictionary items read." << std::endl; + std::wcerr << dictionary.size() << " dictionary items read." << std::endl; } if (!enSentenceList.empty()) @@ -266,7 +267,7 @@ { subsetLookup.add( dictionary[i].second, i+1 ); // !!! i+1 } - std::cerr << "Index tree built." << std::endl; + std::wcerr << "Index tree built." << std::endl; } for ( size_t i=0; iname << "'" << endl; + wcerr << "Error: unexpected rvalue expression '" << element->name << "'" << endl; exit(EXIT_FAILURE); } @@ -710,7 +710,7 @@ } else { - cerr << "Error: you must specify either 'name' or 'namefrom' for the 'chunk' element" << endl; + wcerr << "Error: you must specify either 'name' or 'namefrom' for the 'chunk' element" << endl; exit(EXIT_FAILURE); } } @@ -726,7 +726,7 @@ } else { - cerr << "Error: you must specify either 'name' or 'namefrom' for the 'chunk' element" << endl; + wcerr << "Error: you must specify either 'name' or 'namefrom' for the 'chunk' element" << endl; exit(EXIT_FAILURE); } } @@ -1898,10 +1898,10 @@ { if(trace_att) { - cerr << "Loop start " << endl; - cerr << "ms.size: " << ms.size() << endl; + wcerr << "Loop start " << endl; + wcerr << "ms.size: " << ms.size() << endl; - cerr << "tmpword.size(): " << tmpword.size() << endl; + wcerr << "tmpword.size(): " << tmpword.size() << endl; for (unsigned int ind = 0; ind < tmpword.size(); ind++) { if(ind != 0) @@ -1912,7 +1912,7 @@ } wcerr << endl; - cerr << "tmpblank.size(): " << tmpblank.size() << endl; + wcerr << "tmpblank.size(): " << tmpblank.size() << endl; for (unsigned int ind = 0; ind < tmpblank.size(); ind++) { wcerr << L"'"; @@ -1921,8 +1921,8 @@ } wcerr << endl; - cerr << "last: " << last << endl; - cerr << "prev_last: " << prev_last << endl << endl; + wcerr << "last: " << last << endl; + wcerr << "prev_last: " << prev_last << endl << endl; } if(ms.size() == 0) @@ -1933,7 +1933,7 @@ if(trace_att) { - cerr << "num_words_to_consume: " << num_words_to_consume << endl; + wcerr << "num_words_to_consume: " << num_words_to_consume << endl; } //Consume all the words from the input which matched the rule. @@ -1980,7 +1980,7 @@ { if(trace_att) { - cerr << "printing tmpword[0]" < tr; @@ -2087,7 +2087,7 @@ { if(trace_att) { - cerr << "printing tmpblank[0]" <c_str(), output); tmpblank.clear(); @@ -2147,7 +2147,7 @@ break; default: - cerr << "Error: Unknown input token." << endl; + wcerr << "Error: Unknown input token." << endl; return; } } Index: trunk/apertium/apertium/transfer_mult.cc =================================================================== --- trunk/apertium/apertium/transfer_mult.cc (revision 69687) +++ trunk/apertium/apertium/transfer_mult.cc (revision 69688) @@ -135,7 +135,7 @@ FILE *in = fopen(fstfile.c_str(), "r"); if(!in) { - cerr << "Error: Could not open file '" << fstfile << "'." << endl; + wcerr << "Error: Could not open file '" << fstfile << "'." << endl; exit(EXIT_FAILURE); } fstp.load(in); @@ -150,7 +150,7 @@ FILE *in = fopen(datafile.c_str(), "r"); if(!in) { - cerr << "Error: Could not open file '" << datafile << "'." << endl; + wcerr << "Error: Could not open file '" << datafile << "'." << endl; exit(EXIT_FAILURE); } readData(in); Index: trunk/apertium/apertium/transferpp.cc =================================================================== --- trunk/apertium/apertium/transferpp.cc (revision 69687) +++ trunk/apertium/apertium/transferpp.cc (revision 69688) @@ -30,7 +30,7 @@ if(argc != 3) { - cerr << "USAGE: " << basename(argv[0]) << " rules_file transfer_file" << endl; + wcerr << "USAGE: " << basename(argv[0]) << " rules_file transfer_file" << endl; exit(EXIT_FAILURE); } Index: trunk/apertium/apertium/trx_reader.cc =================================================================== --- trunk/apertium/apertium/trx_reader.cc (revision 69687) +++ trunk/apertium/apertium/trx_reader.cc (revision 69688) @@ -166,7 +166,7 @@ reader = xmlReaderForFile(filename.c_str(), NULL, 0); if(reader == NULL) { - cerr << "Error: Cannot open '" << filename << "'." << endl; + wcerr << "Error: Cannot open '" << filename << "'." << endl; exit(EXIT_FAILURE); } @@ -355,8 +355,8 @@ FILE *out = fopen(filename.c_str(), "wb"); if(!out) { - cerr << "Error: cannot open '" << filename; - cerr << "' for writing" << endl; + wcerr << "Error: cannot open '" << filename; + wcerr << "' for writing" << endl; exit(EXIT_FAILURE); } Index: trunk/apertium/apertium/tsx_reader.cc =================================================================== --- trunk/apertium/apertium/tsx_reader.cc (revision 69687) +++ trunk/apertium/apertium/tsx_reader.cc (revision 69688) @@ -518,7 +518,7 @@ reader = xmlReaderForFile(filename.c_str(), NULL, 0); if(reader == NULL) { - cerr << "Error: Cannot open '" << filename << "'." << endl; + wcerr << "Error: Cannot open '" << filename << "'." << endl; exit(EXIT_FAILURE); }