#include //#include #include #include #include #include #include #include #include "TypeDef.h" #include "PhraseDictionaryTree.h" #include "ConfusionNet.h" #include "FactorCollection.h" #include "Phrase.h" #include "InputFileStream.h" #include "Timer.h" using namespace std; Timer timer; template std::ostream& operator<<(std::ostream& out,const std::vector& x) { out<::const_iterator iend=x.end(); for(typename std::vector::const_iterator i=x.begin();i!=iend;++i) out<<*i<<' '; return out; } inline bool existsFile(const char* filename) { struct stat mystat; return (stat(filename,&mystat)==0); } inline bool existsFile(const std::string& filename) { return existsFile(filename.c_str()); } int main(int argc,char **argv) { std::string fto;size_t noScoreComponent=5;int cn=0; bool aligninfo=false; std::vector > > ftts; int verb=0; for(int i=1;i p; p.first=argv[++i]; p.second=argv[++i]; ftts.push_back(std::make_pair(std::string(argv[++i]),p)); } else if(s=="-nscores") noScoreComponent=atoi(argv[++i]); else if(s=="-out") fto=std::string(argv[++i]); else if(s=="-cn") cn=1; else if(s=="-irst") cn=2; else if(s=="-alignment-info") aligninfo=true; else if(s=="-v") verb=atoi(argv[++i]); else if(s=="-h") { std::cerr<<"usage "< pdicts; std::vector factorOrder; for(size_t i=0;iGetInputFactorType()); PhraseDictionaryTree &pdt=*pdtptr; pdicts.push_back(pdtptr); std::string facStr="."+std::string(ftts[i].second.first)+"-"+std::string(ftts[i].second.second); std::string prefix=ftts[i].first+facStr; if(!existsFile(prefix+".binphr.idx")) { std::cerr<<"bin ttable does not exist -> create it\n"; InputFileStream in(prefix); pdt.Create(in,prefix); } std::cerr<<"reading bin ttable\n"; pdt.Read(prefix); } std::cerr<<"processing stdin\n"; if(!cn) { std::string line; while(getline(std::cin,line)) { std::istringstream is(line); #if 0 std::vector f; std::copy(std::istream_iterator(is), std::istream_iterator(), std::back_inserter(f)); #endif std::cerr<<"got source phrase '"< f(F.GetSize()); for(size_t i=0;iToString(); std::stringstream iostA,iostB; std::cerr<<"full phrase processing "< > weights; for(size_t i=0;i(noScoreComponent,1/(1.0*noScoreComponent))); while(net.ReadF(std::cin,factorOrder,cn-1)) { net.Print(std::cerr); GenerateCandidates(net,pdicts,weights,verb); } } #else std::cerr<<"ERROR: these functions are currently broken...\n"; exit(1); #endif } } }