// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include #include #include #include #include "fsa.h" #include "permuter.h" #include "ngram.h" #include "base64.h" using namespace fsa; int main(int argc, char **argv) { const unsigned int MAXQUERY = 10; const unsigned int MAXGRAM = 6; Permuter p; NGram freq_s,gram,sorted_gram; unsigned int freq; Selector s(10); std::string gstr; if(argc!=3){ std::cerr << "usage: " << argv[0] << " plain_count_fsa_file sorted_count_fsa_file" << std::endl; exit(1); } FSA plain_fsa(argv[1]); FSA sorted_fsa(argv[2]); FSA::State state1(plain_fsa),state2(sorted_fsa); while(!std::cin.eof()){ getline(std::cin,gstr); gram.set(gstr); if(gram.length()>1){ sorted_gram.set(gram); sorted_gram.sort(); sorted_gram.uniq(); state1.startWord(gram[0]); for(unsigned int i=1;state1.isValid()&&i