From 2a4fd2dac126cb5753ae32b6ea3ba1255551a810 Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Tue, 7 Aug 2012 21:26:55 -0400 Subject: random tree code --- rst_parser/Makefile.am | 5 ++++- rst_parser/random_tree.cc | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 rst_parser/random_tree.cc diff --git a/rst_parser/Makefile.am b/rst_parser/Makefile.am index 4977f584..8650cdab 100644 --- a/rst_parser/Makefile.am +++ b/rst_parser/Makefile.am @@ -1,5 +1,5 @@ bin_PROGRAMS = \ - mst_train rst_train rst_parse + mst_train rst_train rst_parse random_tree noinst_LIBRARIES = librst.a @@ -14,4 +14,7 @@ rst_train_LDADD = librst.a $(top_srcdir)/decoder/libcdec.a $(top_srcdir)/mteval/ rst_parse_SOURCES = rst_parse.cc rst_parse_LDADD = librst.a $(top_srcdir)/decoder/libcdec.a $(top_srcdir)/mteval/libmteval.a $(top_srcdir)/utils/libutils.a ../klm/lm/libklm.a ../klm/util/libklm_util.a -lz +random_tree_SOURCES = random_tree.cc +random_tree_LDADD = librst.a $(top_srcdir)/decoder/libcdec.a $(top_srcdir)/mteval/libmteval.a $(top_srcdir)/utils/libutils.a ../klm/lm/libklm.a ../klm/util/libklm_util.a -lz + AM_CPPFLAGS = -W -Wall -Wno-sign-compare $(GTEST_CPPFLAGS) -I$(top_srcdir)/decoder -I$(top_srcdir)/training -I$(top_srcdir)/utils -I$(top_srcdir)/mteval -I../klm diff --git a/rst_parser/random_tree.cc b/rst_parser/random_tree.cc new file mode 100644 index 00000000..23e6e7f7 --- /dev/null +++ b/rst_parser/random_tree.cc @@ -0,0 +1,36 @@ +#include "arc_factored.h" + +#include +#include +#include +#include + +#include "timing_stats.h" +#include "arc_ff.h" +#include "dep_training.h" +#include "stringlib.h" +#include "filelib.h" +#include "tdict.h" +#include "weights.h" +#include "rst.h" +#include "global_ff.h" + +using namespace std; +namespace po = boost::program_options; + +int main(int argc, char** argv) { + if (argc != 2) { + cerr << argv[0] << " N\n" << endl; + return 1; + } + MT19937 rng; + unsigned n = atoi(argv[1]); + + ArcFactoredForest forest(n); + TreeSampler ts(forest); + EdgeSubset tree; + ts.SampleRandomSpanningTree(&tree, &rng); + cout << tree << endl; + return 0; +} + -- cgit v1.2.3