mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-25 21:03:22 +03:00
57 lines
1.5 KiB
C++
57 lines
1.5 KiB
C++
#include "moses/TranslationModel/UG/mm/ug_mm_ttrack.h"
|
|
#include "moses/TranslationModel/UG/mm/ug_mm_tsa.h"
|
|
#include "moses/TranslationModel/UG/mm/tpt_tokenindex.h"
|
|
#include "moses/TranslationModel/UG/mm/ug_corpus_token.h"
|
|
#include "moses/TranslationModel/UG/mm/ug_typedefs.h"
|
|
#include "moses/TranslationModel/UG/mm/tpt_pickler.h"
|
|
#include "moses/TranslationModel/UG/mm/ug_bitext.h"
|
|
#include "moses/TranslationModel/UG/mm/ug_lexical_phrase_scorer2.h"
|
|
|
|
#include "moses/TranslationModel/UG/generic/file_io/ug_stream.h"
|
|
|
|
// using namespace Moses;
|
|
using namespace ugdiss;
|
|
|
|
|
|
typedef L2R_Token<SimpleWordId> Token;
|
|
TokenIndex V;
|
|
sptr<vector<vector<Token> > > C(new vector<vector<Token> >());
|
|
void
|
|
add_file(string fname)
|
|
{
|
|
filtering_istream in;
|
|
open_input_stream(fname,in);
|
|
string line;
|
|
while (getline(in,line))
|
|
{
|
|
C->push_back(vector<Token>());
|
|
fill_token_seq(V,line,C->back());
|
|
}
|
|
}
|
|
|
|
int
|
|
main(int argc, char* argv[])
|
|
{
|
|
V.setDynamic(true);
|
|
add_file(argv[1]);
|
|
sptr<imTtrack<Token> > T(new imTtrack<Token>(C));
|
|
imTSA<Token> I(T,NULL,NULL);
|
|
string line;
|
|
while (getline(cin,line))
|
|
{
|
|
vector<Token> seq; fill_token_seq<Token>(V,line,seq);
|
|
for (size_t i = 0; i < seq.size(); ++i)
|
|
{
|
|
TSA<Token>::tree_iterator m(&I);
|
|
cout << V[seq[i].id()];
|
|
for (size_t k = i; k < seq.size() && m.extend(seq[k]); ++k)
|
|
{
|
|
cout << " ";
|
|
if (k > i) cout << V[seq[k].id()] << " ";
|
|
cout << "[" << m.approxOccurrenceCount() << "]";
|
|
}
|
|
cout << endl;
|
|
}
|
|
}
|
|
}
|