diff options
author | graehl@gmail.com <graehl@gmail.com@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-08-15 05:05:19 +0000 |
---|---|---|
committer | graehl@gmail.com <graehl@gmail.com@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-08-15 05:05:19 +0000 |
commit | c142f3bde0fa673ddb3f6fc7ed3d08e71f8ff8eb (patch) | |
tree | f94444f0c7652955313135f4bdf120359324ef89 /decoder/cfg_test.cc | |
parent | f930e4efe2c594ac87ea650841fcb751159e909c (diff) |
fixed binarization. test
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@554 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'decoder/cfg_test.cc')
-rwxr-xr-x | decoder/cfg_test.cc | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/decoder/cfg_test.cc b/decoder/cfg_test.cc index c4c37a2c..81efa768 100755 --- a/decoder/cfg_test.cc +++ b/decoder/cfg_test.cc @@ -3,18 +3,27 @@ #include "hg_test.h" #include "cfg_options.h" +#define CSHOW_V 1 +#if CSHOW_V +# define CSHOWDO(x) x +#else +# define CSHOWDO(x) +#endif +#define CSHOW(x) CSHOWDO(cerr<<#x<<'='<<x<<endl;) + struct CFGTest : public HGSetup { CFGTest() { } ~CFGTest() { } static void JsonFN(Hypergraph hg,CFG &cfg,std::string file ,std::string const& wts="Model_0 1 EgivenF 1 f1 1") { - FeatureVector v; + FeatureVector featw; istringstream ws(wts); -// ASSERT_TRUE(ws>>v); + EXPECT_TRUE(ws>>featw); + CSHOW(featw) HGSetup::JsonTestFile(&hg,file); -// hg.Reweight(v); - cfg.Init(hg,true,false,false); + hg.Reweight(featw); + cfg.Init(hg,true,true,false); } static void SetUpTestCase() { @@ -27,10 +36,22 @@ TEST_F(CFGTest,Binarize) { Hypergraph hg; CFG cfg; JsonFN(hg,cfg,perro_json,perro_wts); + CSHOW("\nCFG Test.\n"); + CFGBinarize b; CFGFormat form; - form.features=true; - cerr<<"\nCFG Test.\n\n"; - cfg.Print(cerr,form); + form.nt_span=true; + for (int i=-1;i<16;++i) { + b.bin_l2r=i>=0; + b.bin_unary=i&1; + b.bin_name_nts=i&2; + b.bin_uniq=i&4; + b.bin_topo=i&8; + CFG cc=cfg; + EXPECT_EQ(cc,cfg); + CSHOW("\nBinarizing: "<<b); + cc.Binarize(b); + CSHOWDO(cc.Print(cerr,form);cerr<<"\n\n";); + } } int main(int argc, char **argv) { |