summaryrefslogtreecommitdiff
path: root/decoder/cfg_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'decoder/cfg_test.cc')
-rwxr-xr-xdecoder/cfg_test.cc35
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) {